本文介绍了使用png或svg图像作为graphviz节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在graphviz中使用自定义图像节点(节点 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:数据[arrowhead = vee,arrowtail = dot,dir = both,tailclip = false,arrowsize = 1.2];
b:ref:c - > c:数据[arrowhead = vee,arrowtail = dot,dir = both,tailclip = false];
c:ref:c - > d [arrowhead = vee,arrowtail = dot,dir = both,tailclip = false];
}
不幸的是,图片没有出现:
dot -v -Tpng list.dot -o list.png
我的代码,包括png图片,。
如何使用替换节点 d
使用我的自定义图像?
解决方案
只需为此节点定义其他形状,示例 shape = none
:
d [shape = none,label = ,image =X_Shape_Pillar_Yellow.png];
记录
形状定义为默认值不显示图像,而无
,框
甚至明文
do。
同时,将标签设置为空可能是个好主意。
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?
解决方案
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.
这篇关于使用png或svg图像作为graphviz节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!