graphviz 输出 svg

发布于 2024-08-18 11:55:49 字数 5182 浏览 5 评论 0原文

我使用 graphviz 获取 svg

dot -Tsvg graph.dot -o file
  1. 如何将 Graphviz 输出 svg 设置为“矩形”节点而不是“多边形”
  2. ,并将翻译设置为 (0,0) 而不是 (4 256)

非常感谢

<g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 256)">
<polygon fill="white" stroke="white" points="-4,5 -4,-256 265,-256 265,5 -4,5"/>

digraph G {
        a1 [id=a1 shape=rectangle];
        a2 [id=a2 shape=rectangle];
        a3 [id=a3 shape=rectangle];
        a4 [id=a4 shape=rectangle];
        a5 [id=a5 shape=rectangle];
        a1 -> a5;
        a2 -> a1;
        a2 -> a5;
        a3 -> a2;
        a4 -> a2;
        a4 -> a4;
}


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.26.0 (20091210.2329)
 -->
<!-- Title: G Pages: 1 -->
<svg width="152pt" height="260pt"
 viewBox="0.00 0.00 152.00 260.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 256)">
<title>G</title>
<polygon fill="white" stroke="white" points="-4,5 -4,-256 149,-256 149,5 -4,5"/>
<!-- a1 -->
<g id="a1" class="node"><title>a1</title>
<polygon fill="none" stroke="black" points="63,-108 9,-108 9,-72 63,-72 63,-108"/>
<text text-anchor="middle" x="36" y="-86.4" font-family="Times Roman,serif" font-size="14.00">a1</text>
</g>
<!-- a5 -->
<g id="a5" class="node"><title>a5</title>
<polygon fill="none" stroke="black" points="90,-36 36,-36 36,-1.77636e-14 90,-3.55271e-15 90,-36"/>
<text text-anchor="middle" x="63" y="-14.4" font-family="Times Roman,serif" font-size="14.00">a5</text>
</g>
<!-- a1&#45;&gt;a5 -->
<g id="edge2" class="edge"><title>a1&#45;&gt;a5</title>
<path fill="none" stroke="black" d="M42.8132,-71.8314C45.7644,-63.9617 49.2858,-54.5712 52.555,-45.8533"/>
<polygon fill="black" stroke="black" points="55.8609,-47.0055 56.095,-36.4133 49.3066,-44.5476 55.8609,-47.0055"/>
</g>
<!-- a2 -->
<g id="a2" class="node"><title>a2</title>
<polygon fill="none" stroke="black" points="90,-180 36,-180 36,-144 90,-144 90,-180"/>
<text text-anchor="middle" x="63" y="-158.4" font-family="Times Roman,serif" font-size="14.00">a2</text>
</g>
<!-- a2&#45;&gt;a1 -->
<g id="edge4" class="edge"><title>a2&#45;&gt;a1</title>
<path fill="none" stroke="black" d="M56.1868,-143.831C53.2356,-135.962 49.7142,-126.571 46.445,-117.853"/>
<polygon fill="black" stroke="black" points="49.6934,-116.548 42.905,-108.413 43.1391,-119.006 49.6934,-116.548"/>
</g>
<!-- a2&#45;&gt;a5 -->
<g id="edge6" class="edge"><title>a2&#45;&gt;a5</title>
<path fill="none" stroke="black" d="M66.8413,-143.6C68.8166,-133.203 71.0123,-119.935 72,-108 73.3197,-92.0545 73.3197,-87.9455 72,-72 71.3055,-63.6085 70.0138,-54.5578 68.6214,-46.3092"/>
<polygon fill="black" stroke="black" points="72.0544,-45.6235 66.8413,-36.3999 65.1647,-46.8612 72.0544,-45.6235"/>
</g>
<!-- a3 -->
<g id="a3" class="node"><title>a3</title>
<polygon fill="none" stroke="black" points="54,-252 2.4869e-14,-252 0,-216 54,-216 54,-252"/>
<text text-anchor="middle" x="27" y="-230.4" font-family="Times Roman,serif" font-size="14.00">a3</text>
</g>
<!-- a3&#45;&gt;a2 -->
<g id="edge8" class="edge"><title>a3&#45;&gt;a2</title>
<path fill="none" stroke="black" d="M36.0843,-215.831C40.0615,-207.877 44.8155,-198.369 49.2139,-189.572"/>
<polygon fill="black" stroke="black" points="52.4517,-190.923 53.7934,-180.413 46.1907,-187.792 52.4517,-190.923"/>
</g>
<!-- a4 -->
<g id="a4" class="node"><title>a4</title>
<polygon fill="none" stroke="black" points="126,-252 72,-252 72,-216 126,-216 126,-252"/>
<text text-anchor="middle" x="99" y="-230.4" font-family="Times Roman,serif" font-size="14.00">a4</text>
</g>
<!-- a4&#45;&gt;a2 -->
<g id="edge10" class="edge"><title>a4&#45;&gt;a2</title>
<path fill="none" stroke="black" d="M89.9157,-215.831C85.9385,-207.877 81.1845,-198.369 76.7861,-189.572"/>
<polygon fill="black" stroke="black" points="79.8093,-187.792 72.2066,-180.413 73.5483,-190.923 79.8093,-187.792"/>
</g>
<!-- a4&#45;&gt;a4 -->
<g id="edge12" class="edge"><title>a4&#45;&gt;a4</title>
<path fill="none" stroke="black" d="M126.241,-247.487C136.024,-247.777 144,-243.281 144,-234 144,-228.199 140.884,-224.268 136.159,-222.206"/>
<polygon fill="black" stroke="black" points="136.687,-218.745 126.241,-220.513 135.509,-225.646 136.687,-218.745"/>
</g>
</g>
</svg>

I use graphviz to get the svg back

dot -Tsvg graph.dot -o file
  1. How to set the Graphviz output svg to "rect" node not "polygon"
  2. and the translate is set to (0,0) not (4 256)

thanks a lot

<g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 256)">
<polygon fill="white" stroke="white" points="-4,5 -4,-256 265,-256 265,5 -4,5"/>

digraph G {
        a1 [id=a1 shape=rectangle];
        a2 [id=a2 shape=rectangle];
        a3 [id=a3 shape=rectangle];
        a4 [id=a4 shape=rectangle];
        a5 [id=a5 shape=rectangle];
        a1 -> a5;
        a2 -> a1;
        a2 -> a5;
        a3 -> a2;
        a4 -> a2;
        a4 -> a4;
}


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.26.0 (20091210.2329)
 -->
<!-- Title: G Pages: 1 -->
<svg width="152pt" height="260pt"
 viewBox="0.00 0.00 152.00 260.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 256)">
<title>G</title>
<polygon fill="white" stroke="white" points="-4,5 -4,-256 149,-256 149,5 -4,5"/>
<!-- a1 -->
<g id="a1" class="node"><title>a1</title>
<polygon fill="none" stroke="black" points="63,-108 9,-108 9,-72 63,-72 63,-108"/>
<text text-anchor="middle" x="36" y="-86.4" font-family="Times Roman,serif" font-size="14.00">a1</text>
</g>
<!-- a5 -->
<g id="a5" class="node"><title>a5</title>
<polygon fill="none" stroke="black" points="90,-36 36,-36 36,-1.77636e-14 90,-3.55271e-15 90,-36"/>
<text text-anchor="middle" x="63" y="-14.4" font-family="Times Roman,serif" font-size="14.00">a5</text>
</g>
<!-- a1->a5 -->
<g id="edge2" class="edge"><title>a1->a5</title>
<path fill="none" stroke="black" d="M42.8132,-71.8314C45.7644,-63.9617 49.2858,-54.5712 52.555,-45.8533"/>
<polygon fill="black" stroke="black" points="55.8609,-47.0055 56.095,-36.4133 49.3066,-44.5476 55.8609,-47.0055"/>
</g>
<!-- a2 -->
<g id="a2" class="node"><title>a2</title>
<polygon fill="none" stroke="black" points="90,-180 36,-180 36,-144 90,-144 90,-180"/>
<text text-anchor="middle" x="63" y="-158.4" font-family="Times Roman,serif" font-size="14.00">a2</text>
</g>
<!-- a2->a1 -->
<g id="edge4" class="edge"><title>a2->a1</title>
<path fill="none" stroke="black" d="M56.1868,-143.831C53.2356,-135.962 49.7142,-126.571 46.445,-117.853"/>
<polygon fill="black" stroke="black" points="49.6934,-116.548 42.905,-108.413 43.1391,-119.006 49.6934,-116.548"/>
</g>
<!-- a2->a5 -->
<g id="edge6" class="edge"><title>a2->a5</title>
<path fill="none" stroke="black" d="M66.8413,-143.6C68.8166,-133.203 71.0123,-119.935 72,-108 73.3197,-92.0545 73.3197,-87.9455 72,-72 71.3055,-63.6085 70.0138,-54.5578 68.6214,-46.3092"/>
<polygon fill="black" stroke="black" points="72.0544,-45.6235 66.8413,-36.3999 65.1647,-46.8612 72.0544,-45.6235"/>
</g>
<!-- a3 -->
<g id="a3" class="node"><title>a3</title>
<polygon fill="none" stroke="black" points="54,-252 2.4869e-14,-252 0,-216 54,-216 54,-252"/>
<text text-anchor="middle" x="27" y="-230.4" font-family="Times Roman,serif" font-size="14.00">a3</text>
</g>
<!-- a3->a2 -->
<g id="edge8" class="edge"><title>a3->a2</title>
<path fill="none" stroke="black" d="M36.0843,-215.831C40.0615,-207.877 44.8155,-198.369 49.2139,-189.572"/>
<polygon fill="black" stroke="black" points="52.4517,-190.923 53.7934,-180.413 46.1907,-187.792 52.4517,-190.923"/>
</g>
<!-- a4 -->
<g id="a4" class="node"><title>a4</title>
<polygon fill="none" stroke="black" points="126,-252 72,-252 72,-216 126,-216 126,-252"/>
<text text-anchor="middle" x="99" y="-230.4" font-family="Times Roman,serif" font-size="14.00">a4</text>
</g>
<!-- a4->a2 -->
<g id="edge10" class="edge"><title>a4->a2</title>
<path fill="none" stroke="black" d="M89.9157,-215.831C85.9385,-207.877 81.1845,-198.369 76.7861,-189.572"/>
<polygon fill="black" stroke="black" points="79.8093,-187.792 72.2066,-180.413 73.5483,-190.923 79.8093,-187.792"/>
</g>
<!-- a4->a4 -->
<g id="edge12" class="edge"><title>a4->a4</title>
<path fill="none" stroke="black" d="M126.241,-247.487C136.024,-247.777 144,-243.281 144,-234 144,-228.199 140.884,-224.268 136.159,-222.206"/>
<polygon fill="black" stroke="black" points="136.687,-218.745 126.241,-220.513 135.509,-225.646 136.687,-218.745"/>
</g>
</g>
</svg>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

給妳壹絲溫柔 2024-08-25 11:55:49
  1. 起,graphviz 不支持

自版本 2.2.1 graphviz-2.2.1

- dotneato/common/svggen.c文件 graphviz-2.2.1.tar.gz›graphviz-2.2.1›dotneato›common›svggen.c
http://graphviz.sourcearchive.com/documentation/2.2.1 /svggen_8c-source.html

尝试搜索“

  1. There is no support of in graphviz as of version 2.2.1

graphviz-2.2.1 - dotneato/common/svggen.c

file graphviz-2.2.1.tar.gz›graphviz-2.2.1›dotneato›common›svggen.c
or http://graphviz.sourcearchive.com/documentation/2.2.1/svggen_8c-source.html

try to search "<polygon" and '<rect'. Zero for second.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文