Search code examples
graphviz

How to change the background color of a edge label in GraphViz


I am wanting to change the background color of an edge label in Graphviz. At the moment the only way I can see of doing this is using an HTML table.

Eg,

edge [len=3,fontcolor=red];
DeviceA -- DeviceB [headlabel=<
    <table border="0" cellborder="0">
        <tr>
            <td bgcolor="white">Head Label</td>
        </tr>
    </table>>
,taillabel="Tail Label"];

What I would like to be able to do is something shorter/cleaner:

edge [len=3,fontcolor=red,bgcolour=white];
DeviceA -- DeviceB [headlabel="Head Label",taillabel="Tail Label"];

Is their an option for this in graphviz?

The reason I am trying to do this is because end labels end up written over edges, which makes the label difficult to read, a background color the same color as the canvas, artificially creates a break in the edge.

Thanks


Solution

  • In GraphViz there is no way to change the Background Colour of an Edge Label. However you can achieve the same by using a HTML Table:

    Eg:

    edge [len=3,fontcolor=red];
    DeviceA -- DeviceB [headlabel=<
        <table border="0" cellborder="0">
            <tr>
                <td bgcolor="white">Head Label</td>
            </tr>
        </table>>
    ,taillabel="Tail Label"];