graphviz - 如何在 graphviz 中使用 Metapost 中的后记作为图像?

标签 graphviz postscript metapost

我在文件 example.mp 上运行 metapost 生成两个 postscript 文件,其中包含:

beginfig(1);
u=1cm;
draw (2u,2u)--(0,0)--(0,3u)--(3u,0)--(0,0);
pickup pencircle scaled 4pt;
for i=0 upto 2:
for j=0 upto 2: drawdot (i*u,j*u); endfor
endfor
endfig;

beginfig(2);
z0 = (0,0); z1 = (60,40);
z2 = (40,90); z3 = (10,70);
z4 = (30,50);
draw z0..z1..z2..z3..z4
endfig;

end

example.1内容是:

%!PS
%%BoundingBox: -2 -2 86 86 
%%HiResBoundingBox: -1.99252 -1.99252 85.28935 85.28935 
%%Creator: MetaPost 2.00
%%CreationDate: 2023.07.15:2110
%%Pages: 1
%%BeginProlog
%%EndProlog
%%Page: 1 1
 0 0 0 setrgbcolor 0 0.5 dtransform truncate idtransform setlinewidth pop
 [] 0 setdash 1 setlinecap 1 setlinejoin 10 setmiterlimit
newpath 56.6929 56.6929 moveto
0 0 lineto
0 85.03935 lineto
85.03935 0 lineto
0 0 lineto stroke
 0 3.98505 dtransform truncate idtransform setlinewidth pop
newpath 0 0 moveto 0 0 rlineto stroke
newpath 0 28.34645 moveto 0 0 rlineto stroke
newpath 0 56.6929 moveto 0 0 rlineto stroke
newpath 28.34645 0 moveto 0 0 rlineto stroke
newpath 28.34645 28.34645 moveto 0 0 rlineto stroke
newpath 28.34645 56.6929 moveto 0 0 rlineto stroke
newpath 56.6929 0 moveto 0 0 rlineto stroke
newpath 56.6929 28.34645 moveto 0 0 rlineto stroke
newpath 56.6929 56.6929 moveto 0 0 rlineto stroke
showpage
%%EOF

我想使用结果 example.1example.2 作为图表中的节点图像。

我运行dot -Tps example.dot -o example.ps

example.dot 的内容是:

strict graph {
    {
        node [shape=none, label=""];
        1 [image="example.1"];
        2 [image="example.2"];
    }
    1 -- 2;
}

我收到警告消息:

Warning: "example.1" was not found as a file or as a shape library member
Warning: No or improper image="example.1" for node "1"
Warning: "example.2" was not found as a file or as a shape library member
Warning: No or improper image="example.2" for node "2"

并且 example.ps 中缺少节点图像。

我怎样才能在结果中看到它们?

最佳答案

Graphviz 似乎不喜欢你的 2 个 Postscript 文件的格式(尽管看起来很合法)。
使用 Ghostscript 来“修复”这些文件 ps2ps example.1 Example.1 或类似文件,修复文件的命名,然后重试。为我工作。

关于graphviz - 如何在 graphviz 中使用 Metapost 中的后记作为图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76695464/

相关文章:

nodes - 将宽图的相同等级上的节点分布到不同的线

postscript - 如何为 postscripts curveto 运算符生成控制点?

image - 渐近线 : resizing the picture (including pen widths and font sizes)

layout - 如何使用metapost生成多边形数字?

pycharm - 在 PyCharm 中可视化点文件

Graphviz:如何使用 circo 布局排列节点

pdf - PostScript - 超链接表,但只有一个链接用于所有链接

pdf - 将 .ps 转换为 .pdf 并删除单个页面

graphviz - 使用 neato 节点之间的多条边