Newline in node label in dot (graphviz) language

僤鯓⒐⒋嵵緔 提交于 2019-12-01 02:39:32

This works for me as documented:

digraph {
    n[label="two\nlines"]
    "on\nthree\nlines"
}

Either put in in a label attribute (my preference), or use it as the node's name, but always enclose it with double quotes.

Try "\\n" that works: dot.node('test', label="line1\\nline2").

You can use \n character

With graphviz package, this would give

from graphviz import Digraph
d=Digraph()
d.node('test',label='line 1\\nline 2')
print(d.source)

This would give

digraph {
    test [label="line 1\nline 2"]
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!