Skip to content

PlantUML Styles and Options

The PlantUML backend supports several layout and styling options that control diagram direction, legend visibility, and overall visual appearance.

See the C4-PlantUML docs for additional information.

Layout Options

Layout behavior is configured via the PlantUMLRenderOptionsBuilder builder:

from c4.renderers.plantuml import PlantUMLRenderOptionsBuilder

render_options = (
    PlantUMLRenderOptionsBuilder()
    .layout_landscape()   # Horizontal layout
    .show_legend()        # Display legend
    .build()
)

You can pass render_options to PlantUMLRenderer.

See the PlantUMLRenderOptionsBuilder reference section for the complete list of available methods and configuration options.

Layout configuration can also be set via RenderOptions.

Unlabeled Relationships

C4-PlantUML rejects Rel(a, b) without a label. A relationship whose label is None (for example a >> b) is therefore written with the placeholder uses: Rel(a, b, "uses"). Change the text with default_relationship_label, or pass None to write the relationship as it is stored:

from c4.renderers.plantuml import PlantUMLRenderOptionsBuilder

render_options = (
    PlantUMLRenderOptionsBuilder()
    .default_relationship_label("relates to")  # or None to turn it off
    .build()
)

An explicit empty label ("") is written as Rel(a, b, ""), not replaced. The placeholder is added at render time; the relationship is not changed.

C4 Visual Styles

Starting July 2025, the official c4model.com website introduced a refreshed visual style for C4 diagrams.

The PlantUML renderer supports both:

  • Classic style (default)
  • New C4 style (opt-in)

Classic Style (Default)

from c4 import (
    Component,
    ComponentDiagram,
    ContainerBoundary,
    Person,
    PNG,
    System,
    SystemBoundary,
)
from c4.contrib.plantuml import RelRight
from c4.renderers.plantuml import (
    PlantUMLRenderer,
    LocalPlantUMLBackend,
    PlantUMLRenderOptionsBuilder,
)


with ComponentDiagram() as diagram:
    admin = Person("Administrator")

    with SystemBoundary("Sample"):
        with ContainerBoundary(
            "Web Application",
            "Allows users to compare\nmultiple Twitter timelines",
        ) as web_app:
            twitter_facade = Component("Twitter Facade")

    twitter = System("Twitter")

    admin >> RelRight("Uses", technology="HTTPS") >> web_app
    twitter_facade >> RelRight("Gets tweets from", technology="HTTPS") >> twitter

    render_options = PlantUMLRenderOptionsBuilder().layout_landscape().show_legend().build()

    renderer = PlantUMLRenderer(
        backend=LocalPlantUMLBackend(),
        render_options=render_options,
    )


renderer.render_file(
    diagram,
    output_path="diagram.png",
    format=PNG,
)

This produces the classic C4 visual style:

old-style
diagram.png

New C4 Style

To enable the updated visual style, pass use_new_c4_style=True to PlantUMLRenderer:

from c4 import (
    Component,
    ComponentDiagram,
    ContainerBoundary,
    Person,
    PNG,
    System,
    SystemBoundary,
)
from c4.contrib.plantuml import RelRight
from c4.renderers.plantuml import PlantUMLRenderer, LocalPlantUMLBackend
from c4.renderers.plantuml import PlantUMLRenderOptionsBuilder


with ComponentDiagram() as diagram:
    admin = Person("Administrator")

    with SystemBoundary("Sample"):
        with ContainerBoundary(
            "Web Application",
            "Allows users to compare\nmultiple Twitter timelines",
        ) as web_app:
            twitter_facade = Component("Twitter Facade")

    twitter = System("Twitter")

    admin >> RelRight("Uses", technology="HTTPS") >> web_app
    twitter_facade >> RelRight("Gets tweets from", technology="HTTPS") >> twitter

    render_options = PlantUMLRenderOptionsBuilder().layout_landscape().show_legend().build()

    renderer = PlantUMLRenderer(
        backend=LocalPlantUMLBackend(),
        render_options=render_options,
        use_new_c4_style=True,
    )


renderer.render_file(
    diagram,
    output_path="diagram.png",
    format=PNG,
)

This produces the updated C4 visual style:

new-style
diagram.png