It seems that a new line character is supported for labels and names ( A new line in a node label in dots (graphic language) ), but tooltips are placed directly in the resulting HTML, which does not see "\ n" as a special character.
Using direct character codes is an alternative. (see Formatting and ASCII Control Codes )
node = pydot.Node('abc', style='filled', fillcolor='#CCFF00', fontsize=12) # specify HTML Carriage Return (\r) and/or Line Feed (\n) characters directly txt = 'foo' + ' ' + test' node.set_tooltip(txt)
Or some simple preprocessing will allow you to save the form "\ n":
node.set_tooltip(txt.replace('\n', ' '))
source share