Newline in node label in dot (graphviz) language

M T picture M T · May 31, 2012 · Viewed 31.4k times · Source

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

Answer

marapet picture marapet · Jun 1, 2012

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.