How do I get DOT to display an image for a node?
Asked Answered
B

2

33

I am not having success displaying an image at a node in dot.

My node is defined:

SW103 [image="swOpen.png"]

I can view swOpen.png so I think the file is ok, and it is in the same directory as the code. But dot displays the node using its label "SW103", not as the image.

The documentation mentions that the image file should have size information in it, but I don't know what to put in it.

Could someone point me to an actual example that displays a .png or .bmp file as a node? (include the image file, if I need to add sizing to it)

Babineaux answered 9/11, 2011 at 23:19 Comment(1)
Does running your dot command with the -v switch provide any useful information?Incorporation
H
55

Using a graphviz snapshot from May 2011 (2.29), the following syntax

digraph g{
  imgnode[image="apple-touch-icon.png", label=""];
}

results in

graphviz output

You'll need to set an empty label to prevent the node name from being displayed.

If this is not working for you, you may check the output of dot (something like dot -Tpng -o graph.png graph.gv) - if dot can't find the image, you should be able to see an error message.

I did not have to specify any size (I think this is for svg).

Household answered 10/11, 2011 at 9:10 Comment(2)
I'm getting NSInvalidArgumentException if I give a correct path of image or else no image errorSepaloid
@SaileshKotha Maybe we should specify image not imagenode, also specify imagepath.Hilbert
S
1

For one node you can use the below sample:

xxx.node(SW103 , color='red', image="swOpen.png")

It changed image of SW103 node.

Spectroscopy answered 28/4, 2020 at 9:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.