我尝试在 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: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];
}
不幸的是,图像没有出现:
我使用以下方法编译了点文件:
dot -v -Tpng list.dot -o list.png
我的代码,包括 png 图像,is stored in github .
如何将替换节点 d
与我的自定义图像一起使用?
最佳答案
只需为此节点定义其他形状,例如 shape=none
:
d [shape=none, label="", image="X_Shape_Pillar_Yellow.png"];
默认定义的record
形状不显示图像,而none
、box
甚至plaintext
做。
同时,将标签设置为空可能是个好主意。
关于image - 使用 png 或 svg 图像作为 graphviz 节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15502427/