Closed MonikaBarget closed 3 years ago
Is there any recommended workflow or a recommended Python package that works best with graphviz?
This package graphviz
here is actually a Python package to work with Graphviz (https://www.graphviz.org).
More are here: https://github.com/xflr6/graphviz#see-also
IIUC you are referring to the DOT language syntax, more specifically on the aspect of quoting and escaping. This is something that is abstracted by this library (though quoting and escaping can be tricky so I won't promise there are no edge cases that I am not aware of):
In [1]: import graphviz
...:
...: d = graphviz.Digraph()
...: d.node('spam')
...: d.edge('spam', '"spam"')
...: d.edge('"spam"', 'späm')
...:
...: print(d.source)
...: d
digraph {
spam
spam -> "\"spam\""
"\"spam\"" -> "späm"
}
Out[1]:
Hope that helps.
P.S.: Code is here: https://github.com/xflr6/graphviz/blob/master/graphviz/lang.py
Graphviz can only handle alphanumerical characters and underscores, so it is necessary to "tokenize" texts with many special characters before applying data visualisation and put all strings to be treated as IDs into hyphens.
Is there any recommended workflow or a recommended Python package that works best with graphviz?