Using png or svg image as graphviz node

拟墨画扇 提交于 2019-12-20 12:46:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!