Is There a Way to Include Subscripts in GraphViz/dot Graphs?

  • Thread starter Gavin Harper
  • Start date
  • Tags
    Dot
In summary, there is currently no "native" functionality in GraphViz/dot for including subscripts in graph vertices, but Emden Gansner and Dwight Perry have implemented this feature in the current development snapshot which will soon become the next stable release. It may require using a cairo back end. Some users have resorted to using Tikz in TeX as an alternative.
  • #1
Gavin Harper
17
0
Currently I am forced to use dot2tex to convert my graphs from .dot to .tex for inclusion in a latex document as I cannot find a working method for including subscripts in my graph vertices, for example: v1, v2.

The dot2tex method is fine but I would like to know if a "native" functionality exists within GraphViz/dot.

Thank you
 
Physics news on Phys.org
  • #2
Funny you should ask. Emden Gansner and Dwight Perry implemented this feature in the current development snapshot, which in a few days should become the next stable release. It may require using a cairo back end (e.g. -Tpng:cairo).
 
  • #3
truenorth said:
Funny you should ask. Emden Gansner and Dwight Perry implemented this feature in the current development snapshot, which in a few days should become the next stable release. It may require using a cairo back end (e.g. -Tpng:cairo).

Thank you for the update! I am now just using Tikz in TeX now as it also avoids the redundant step of compiling a separate file.
 

1. What are subscripts in DOT (GraphViz)?

Subscripts in DOT (GraphViz) are used to add text or symbols below or above a node or edge in a graph. They are commonly used to represent mathematical equations, chemical formulas, or other specialized notations.

2. How do I add subscripts in DOT (GraphViz)?

To add a subscript in DOT (GraphViz), you can use the label attribute and enclose the subscript text in curly braces and preceded by the tilde symbol (~). For example, node1[label="~H2O~"]; will add the subscript "H2O" below the node named "node1".

3. Can I use multiple subscripts in DOT (GraphViz)?

Yes, you can use multiple subscripts in DOT (GraphViz) by separating them with a space. For example, node1[label="~H2O~ ~+~ ~CO2~"]; will add two subscripts, "H2O" and "CO2", below the node named "node1".

4. Are there any limitations when using subscripts in DOT (GraphViz)?

Yes, there are a few limitations when using subscripts in DOT (GraphViz). Subscripts cannot be used in conjunction with HTML-like labels, and they cannot be used in attributes other than label. Additionally, certain characters such as angle brackets, double quotes, and the tilde symbol itself, must be escaped with a backslash.

5. Can I change the position or size of subscripts in DOT (GraphViz)?

No, there is no built-in way to change the position or size of subscripts in DOT (GraphViz). However, you can use HTML-like labels to achieve this by using the port attribute and specifying the desired position and size for the subscript text. This method requires more advanced knowledge of the DOT (GraphViz) syntax.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
541
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Replies
14
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Advanced Physics Homework Help
Replies
6
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Special and General Relativity
Replies
13
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
272
Back
Top