How to set width and height of output image in Pygraphviz

I create a .png file as follows:

import pygraphviz as pgv G = pgv.AGraph() G.add_nodes("a") G.add_edge("b", "c") G.layout() G.draw("output.png") 

How to set the size of the output image?

+4
source share
1 answer

You can set the maximum size of your output image by setting the size , which is an attribute of the chart object. For instance.

 digraph "my_graph" { graph[ fontname = "Helvetica-Oblique", fontsize = 12, label = "some label", size = "7.75,10.25" ]; node [ shape = polygon, sides = 4 ]; } 

In this example, I set the size of the graph to 7.75 x 10.25, the size of which you want to make sure that your graph is suitable for a sheet of 8.5 x 11 inches, and also so that it occupies all the space on this sheet.

+4
source

All Articles