Newline in node label in dot (graphviz) language

前端 未结 3 1747
暖寄归人
暖寄归人 2021-01-07 16:25

Does anyone know how to put newline in the label of the node? \\n is not working - instead some new nodes appear.

相关标签:
3条回答
  • 2021-01-07 16:34

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

    0 讨论(0)
  • 2021-01-07 16:34

    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"]
    }
    
    0 讨论(0)
  • 2021-01-07 16:43

    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.

    0 讨论(0)
提交回复
热议问题