graphviz

How to use "<f0>" and italics together in labels in .gv files?


I want to make the letters in italics but keep the digits regular. How should I adjust my codes? Here are the original .gv codes.

digraph c {
    node [height=.1 shape=record]
    c [label="{<f0>c|<f1>134.0|<f2>45.5|<f3>88.5|<f4>2}"]
    cf [label="{<f0>cf|<f1>122.0|<f2>73.5|<f3>48.5|<f4>1}"]
    c:f4 -> cf:f0
    cfb [label="{<f0>cfb|<f1>106.5|<f2>106.5|<f3>0.0|<f4>0}"]
    cf:f4 -> cfb:f0
    cb [label="{<f0>cb|<f1>85.5|<f2>85.5|<f3>0.0|<f4>0}"]
    c:f4 -> cb:f0
}

Original PDF

Attempt 1: Add <I></I> directly. That is,

digraph c {
    node [height=.1 shape=record]
    c [label="{<f0><I>c</I>|<f1>134.0|<f2>45.5|<f3>88.5|<f4>2}"]
    cf [label="{<f0><I>cf</I>|<f1>122.0|<f2>73.5|<f3>48.5|<f4>1}"]
    c:f4 -> cf:f0
    cfb [label="{<f0><I>cfb</I>|<f1>106.5|<f2>106.5|<f3>0.0|<f4>0}"]
    cf:f4 -> cfb:f0
    cb [label="{<f0><I>cb</I>|<f1>85.5|<f2>85.5|<f3>0.0|<f4>0}"]
    c:f4 -> cb:f0
}

However, it failed.

dot -Tpdf -O C:\Users\Universe\Desktop\test.gv
Error: bad label format {<f0><I>c</I>|<f1>134.0|<f2>45.5|<f3>88.5|<f4>2}
Error: bad label format {<f0><I>cf</I>|<f1>122.0|<f2>73.5|<f3>48.5|<f4>1}
Error: bad label format {<f0><I>cfb</I>|<f1>106.5|<f2>106.5|<f3>0.0|<f4>0}
Error: bad label format {<f0><I>cb</I>|<f1>85.5|<f2>85.5|<f3>0.0|<f4>0}
Warning: node c, port f4 unrecognized
Warning: node cf, port f0 unrecognized
Warning: node c, port f4 unrecognized
Warning: node cb, port f0 unrecognized
Warning: node cf, port f4 unrecognized
Warning: node cfb, port f0 unrecognized

Attempt 2: Use <I></I> only.

digraph c {
    node [height=.1 shape=record]
    c [label=<<I>c</I>>]
}

It can be compiled successfully. However, I do not know how to make the connection lines like the original codes do.

** Attempt 3 **: Use <<I>X</I>> to escape. That is,

digraph c {
    node [height=.1 shape=record]
    c [label="{<f0><<I>c</I>>|<f1>134.0|<f2>45.5|<f3>88.5|<f4>2}"]
    cf [label="{<f0><<I>cf</I>>|<f1>122.0|<f2>73.5|<f3>48.5|<f4>1}"]
    c:f4 -> cf:f0
    cfb [label="{<f0><<I>cfb</I>>|<f1>106.5|<f2>106.5|<f3>0.0|<f4>0}"]
    cf:f4 -> cfb:f0
    cb [label="{<f0><<I>cb</I>>|<f1>85.5|<f2>85.5|<f3>0.0|<f4>0}"]
    c:f4 -> cb:f0
}

However, it failed again.

dot -Tpdf -O C:\Users\Universe\Desktop\test.gv
Error: bad label format {<f0><<I>c</I>>|<f1>134.0|<f2>45.5|<f3>88.5|<f4>2}
Error: bad label format {<f0><<I>cf</I>>|<f1>122.0|<f2>73.5|<f3>48.5|<f4>1}
Error: bad label format {<f0><<I>cfb</I>>|<f1>106.5|<f2>106.5|<f3>0.0|<f4>0}
Error: bad label format {<f0><<I>cb</I>>|<f1>85.5|<f2>85.5|<f3>0.0|<f4>0}
Warning: node c, port f4 unrecognized
Warning: node cf, port f0 unrecognized
Warning: node c, port f4 unrecognized
Warning: node cb, port f0 unrecognized
Warning: node cf, port f4 unrecognized
Warning: node cfb, port f0 unrecognized

What I Expect: The following figure with letters in italics.

Expected PDF

Thank you so much.


Solution

  • Don't believe that can be done with record labels, but here it is using HTML records:

    digraph c {
        node [shape=plain]
    
        C [label=<<table>
           <tr><td port="f0"><i>CowBoy</i></td></tr>
           <tr><td port="f1">134.0</td></tr>
           <tr><td port="f2">45.5</td></tr>
           <tr><td port="f3">88.5</td></tr>
           </table>>]
    }
    

    Giving:
    enter image description here