I am having problem including image in node in graphviz. I tried both including image in node via image="name.svg"
and via <IMG SRC="name.svg" />
in HTML-like label. I also tried using different image formats (svg, jpg, png), but when exporting I always get message:
Warning: No such file or directory while opening name.svg
Warning: No or improper image="name.svg" for node "somenode"
.dot file looks like:
digraph {
node1[image="image.svg", label=""]
node2[ label=
<A
<IMG SRC="image.svg" />> ]
node1 -> node2 }
image.svg is located in same directory as .dot file (output of ls -la
):
total 96
drwxrwxr-x 2 filip filip 4096 maj 8 07:55 .
drwxr-xr-x 34 filip filip 4096 maj 8 07:56 ..
-rw-rw-r-- 1 filip filip 85030 maj 7 17:05 image.svg
-rw-rw-r-- 1 filip filip 117 maj 8 07:54 mygraph.dot
My OS is Ubuntu 20.04.3 LTS.
I have already looked at many other questions regarding this problem, but none of the solutions given seem to help.
Any suggestions?
When retrying whole process in different ways I found how it should be done, although I don't have enough knowledge to understand why this happens.
The thing is, command dot -Tsvg mygraph.dot > mygraph.svg
must be run from the directory where mygraph.dot is stored. Also, image.svg must be located in this same directory or in one of the subdirectories. If, for example, mygraph.dot is stored inside dir1, running
dot -Tsvg dir1/mygraph.dot > dir1/mygraph.svg
from the parent directory of dir1 won't work.
Also, image inside HTML-like label should be inside a table:
node[ label=
<<TABLE><TR><TD>
<IMG
SRC="/home/filip/dir2/images/image.svg"
/>
</TD></TR></TABLE>>
]
It is possible all this is stated somewhere in the documentation and I just didn't notice.
Also, maybe worth mentioning is that on Ubuntu, if I wanted image.svg embedded in output file, I had to additionaly install librsvg2-dev and librgraphviz-dev packages, then run:
dot -Tsvg:cairo mygraph.dot > mygraph.svg