1

Graphviz's HTML-like labels documentation suggests I can have a node labeled Uₓ with this .dot file:

digraph G {
    U [label=<U<SUB>X</SUB>>];
    U->X
}

Unfortunately, the graph produced shows a node with UX instead of Uₓ:

enter image description here

Am I missing something to make the X in Uₓ subscript?

UPDATE: I'm outputting PNG images with dot mygraph.dot -Tpng -o mygraph.png and receive no warnings or errors. The version is:

$ dot -V
dot - graphviz version 2.40.1 (20161225.0304)

Installed with brew on macOS

UPDATE 2: I tried to output SVG with -Tsvg instead of PNG with -Tpng and I do get a subscript X, sort of. The font size of X is exactly the same as U, just shifted down a little. Why is this so bad?

enter image description here

at.
  • 50,922
  • 104
  • 292
  • 461
  • I got an image that shows a subscript (a bit large though) when using the dot executable directly like `dot -Tpng ...`. When using a web service (http://www.webgraphviz.com/) I got "Warning: Not built with libexpat. Table formatting is not available. in label of node U". Did you get a warning / error ? – albert Oct 31 '19 at 14:11
  • Should work when generating svg - are you? – marapet Oct 31 '19 at 14:18
  • Was going to link the documentation for the limitations as [here](https://stackoverflow.com/questions/17669014/create-graphviz-labels-with-subscripts-from-java-application), but it seems like subscripts don't work with all output formats and versions of graphviz. – marapet Oct 31 '19 at 14:24
  • I use the command `dot mygraph.dot -Tpng > mygraph.png` to generate PNG images. I received zero warnings or errors. – at. Nov 01 '19 at 00:55
  • I'm using dot - graphviz version 2.40.1 (20161225.0304). – at. Nov 01 '19 at 01:00
  • I'm using the same version on Cygwin and here I don't have the problems. – albert Nov 01 '19 at 09:07
  • @albert, are you using the same `.dot` file I posted above? I'm using macOS, maybe graphviz's macOS version has problems with subscripts... – at. Nov 02 '19 at 04:47
  • Yes I did use the example you provided and I also see that the X is not smaller (though it is shifted down a little bit more than in your case). – albert Nov 02 '19 at 09:35

1 Answers1

0

I was not satisfied with my comment so I'll try to give a bit a better overview with what I see (so no answer, but just a summary). For this overview I used the following input:

digraph G {
    U [label=<U<sub>x</sub>>];
    U->X
    V [label=<U<SUB>x</SUB>>];
    V->X
    V1 [label=<Ux>];
    V1->X
    W [label=<U<sub>X</sub>>];
    W->X
    Y [label=<U<SUB>X</SUB>>];
    Y->X
    Y1 [label=<UX>];
    Y1->X
}

and the following versions of dot:

  • Windows: dot - graphviz version 2.38.0 (20140413.2041)
  • Cygwin: dot - graphviz version 2.40.1 (20161225.0304)

The results are as follows:

Windows png:

enter image description here

Windows svg:

enter image description here

Cygwin png:

enter image description here

Cygwin svg:

enter image description here

albert
  • 8,285
  • 3
  • 19
  • 32
  • Interesting, for you, SVG disregards the `` markup and PNG does output subscripts, but poorly. For me, on macOS, it's the opposite. My SVG output looks similar to your PNG and vice-versa. – at. Nov 02 '19 at 17:27