0

I have created a node using pydot and GraphViz as follows:

import pydot
graph = pydot.Dot(graph_type = 'digraph')

a = pydot.Node("First Node", style = "filled", color = "red")
graph.add_node(a)

I want text of node a to be bold. How can I do it? Is there any attribute of the node like style, color? Thank you.

Edit: If I need to add \n in the middle of the text, can I simply put \n in the middle as shown:

<<font face="boldfontname">First\nNode</font>>
Suraj Regmi
  • 193
  • 2
  • 10
  • 1
    Possible duplicate of [Graphviz bold font attribute](https://stackoverflow.com/questions/30194104/graphviz-bold-font-attribute) – 0 _ Nov 21 '17 at 20:43
  • If I need to use breaking the line function, then, shall I do? <>First\nNode>? – Suraj Regmi Nov 22 '17 at 04:31

1 Answers1

0

One possibility (from here) is to use HTML:

import pydot

graph = pydot.Dot(graph_type='digraph')
nd = pydot.Node(
    'First Node',
    label='<<font face="boldfontname">First Node</font>>',
    style='filled',
    color='red')
graph.add_node(nd)
graph.write_pdf('foo.pdf')

Defining a fontname appears to be another possibility.

0 _
  • 10,524
  • 11
  • 77
  • 109