newlinegraphvizdot

Newline in node label in dot (graphviz) language


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


Solution

  • This works for me as documented:

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

    enter image description here (https://dreampuf.github.io/GraphvizOnline/?engine=dot#digraph%20%7B%0D%0A%20%20%20%20n%5Blabel%3D%22two%5Cnlines%22%5D%0D%0A%20%20%20%20%22on%5Cnthree%5Cnlines%22%0D%0A%7D)

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