Newline in node label in dot (graphviz) language

前端 未结 3 1748
暖寄归人
暖寄归人 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

    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"]
    }
    

提交回复
热议问题