Canvas background color

type: color | colorList, default: <none>

When attached to the root graph, this color is used as the background for entire canvas.

When a cluster attribute, it is used as the initial background for the cluster. If a cluster has a filled style, the cluster’s fillcolor will overlay the background color.

If the value is a colorList, a gradient fill is used. By default, this is a linear fill; setting style=radial will cause a radial fill. Only two colors are used. If the second color (after a colon) is missing, the default color is used for it. See also the gradientangle attribute for setting the gradient angle.

For certain output formats, such as PostScript, no fill is done for the root graph unless bgcolor is explicitly set.

For bitmap formats, however, the bits need to be initialized to something, so the canvas is filled with white by default. This means that if the bitmap output is included in some other document, all of the bits within the bitmap’s bounding box will be set, overwriting whatever color or graphics were already on the page. If this effect is not desired, and you only want to set bits explicitly assigned in drawing the graph, set bgcolor="transparent".

graph {
  subgraph cluster_ground_floor {
    label="Ground Floor"
  subgraph cluster_top_floor {
    label="Top Floor"
Valid on:
  • Graphs
  • Clusters

Search the Graphviz codebase for "bgcolor"

Last modified September 18, 2022: Update add description (51135fb)