Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 878
M T Avatar asked May 31 '12 20:05

M T


People also ask

What is the shape of a node?

Shape nodes Holds an object's geometry attributes or attributes other than the object's transform node attributes. A shape node is the child of a transform node. A transform node has only one shape node.

What is the dot language called?

Braille is a system of touch reading and writing for blind persons in which raised dots represent the letters of the alphabet. It also contains equivalents for punctuation marks and provides symbols to show letter groupings. Braille is read by moving the hand or hands from left to right along each line.


2 Answers

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.

like image 89
marapet Avatar answered Oct 17 '22 12:10

marapet


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

like image 8
Dmitriy Avatar answered Oct 17 '22 12:10

Dmitriy