问题
I've tried to use a custom image node in graphviz (node d
):
digraph foo {
rankdir=LR;
node [shape=record];
a [label="{ <data> 12 | <ref> }", width=1.2]
b [label="{ <data> 99 | <ref> }"];
c [label="{ <data> 37 | <ref> }"];
d [image="X_Shape_Pillar_Yellow.png"];
a:ref:c -> b:data [arrowhead=vee, arrowtail=dot, dir=both, tailclip=false, arrowsize=1.2];
b:ref:c -> c:data [arrowhead=vee, arrowtail=dot, dir=both, tailclip=false];
c:ref:c -> d [arrowhead=vee, arrowtail=dot, dir=both, tailclip=false];
}
Unfortunately, the image does not appear:

I've compiled the dot file using:
dot -v -Tpng list.dot -o list.png
My code, including the png image, is stored in github.
How do I use a replace node d
with my custom image?
回答1:
Simply define an other shape for this node, for example shape=none
:
d [shape=none, label="", image="X_Shape_Pillar_Yellow.png"];
The record
shape defined as default does not display the image, whereas none
, box
and even plaintext
do.
At the same time, it may be a good idea to set the label to nothing.
来源:https://stackoverflow.com/questions/15502427/using-png-or-svg-image-as-graphviz-node