Search code examples
nodesgraphviz

How to adapt the node size to image size without breaking the shape of the graph using Graphviz?


I am making graph using images i made, but they all have a different size. When i am building the graph without setting a specific size, the graph build different node size adapting to my images.

different node size

I am modifying the size of the image using Graphviz with the line :

mygraph.node("A", image="./stinkbug.png", width="100", height="100", fixedsize="true")

The images are way smaller than the last ones and have the same size (i censored the images used). But the nodes are too big now. I tried all the fixedsize value available (true, false and shape) and it dont work.

bad not size

In addition, it is breaking the shape of my graph ! Even if i am using the same layout (fdp) in both creation. Going from this shape :

good layout

To this shape :

bad layout


Solution

  • You set the width & height to 100 inches (too big).

    • Continue to use fixedsize
    • Remove the width & height attributes (or change to much smaller values)
    • Add imagescale=true or imagescale=both