Search code examples
graph-theorygraphviz

How can I remove the border around a Graphviz graph file?


Whenever I create a graph and render it to a PNG or PDF I get a border around my image.

This is the simplified dot code:

digraph graphname {
    graph [fontname = "Arial", fontsize=16, bgcolor=3, style=rounded, colorscheme=set39, labelloc=t, ranksep=0.5];
    node [fontname = "Arial", fontsize=12, style=filled, colorscheme=set39]; 
    label="The graph title"
    a -> b
    b -> c
    c -> b
}

example PNG dot diagram showing the black border around the image example PDF dot diagram showing the black border around the image

What option can I use to remove this border? I went through the attribute list but could not find an option that specifies the border color or thickness.


Solution

  • Shortly after I asked this question I stumbled upon a (seemingly unrelated) fix: it's the colorscheme=set39 option of the graph that does this.

    According to the documentation of the color attribute, colors can be set using the "/schemename/colorname" syntax, so I've changed the colorscheme option to x11 (the default), but set bgcolor="/set39/3" effectively having the same color. The border is now gone.

    digraph graphname {
        graph [fontname = "Arial", fontsize=16, bgcolor="/set39/3", style=rounded, colorscheme=x11, labelloc=t, ranksep=0.5];
        node [fontname = "Arial", fontsize=12, style=filled, colorscheme=set39]; 
        label="The graph title"
        a -> b
        b -> c
        c -> b
    }
    

    This is the PNG without border:
    enter image description here

    And here's the PDF:
    enter image description here

    A proper way to configure that border is still welcome though.