如何使用 graphviz 的控制点在两点之间绘制样条曲线?
How to draw a spline curve between 2 points with a control points with graphviz?
我想以红点为控制点在蓝点和绿点之间创建一条样条曲线。
Graphviz 文档说:
- splines attribute,bool 或 string 类型,在 Graphs
上有效
- splineType 模式:
spline ( ';' spline )*
是 pos 属性的有效类型
- pos attribute 在边和节点上有效
我试过这张图
graph G{
layout ="neato" outputorder="edgesfirst" splines="true"
a[shape="point" pos="0,0!" color="blue"]
b[shape="point" pos="1,0!" color="green"]
c[shape="point" pos=" 0.5,0.5!" color="red"]
a -- b [pos="e,1,0 s,0,0 0.5,0.5!"]
}
然后 Windows 10 PowerShell :
neato.exe -Tsvg .\spline.dot > .\spline.svg
和
neato - graphviz version 2.49.3 (20211023.0002)
结果
实现此目标的正确方法是什么?
谢谢。
关闭,但是...
- !符号似乎只适用于节点(不是边缘)(记录不多,但请参阅:https://graphviz.org/docs/attr-types/point/ and https://graphviz.org/docs/attrs/pin/)
- 默认情况下,pos值单位是点(inch/72)。你的值太小了
- neato -n2 将使用您提供的节点和边值 (https://graphviz.org/faq/#FaqDotWithCoords)
- 所有边(不仅仅是曲线)都被定义为三次 B 样条,并由 1 + n*3 个点(n 是整数 >=1)(https://graphviz.org/docs/attr-types/splineType/)(即 4 或 7 或11 或 ...)
所以:
graph G{
// default units for pos values are in points (72/inch)
// multiplied by 100 out of laziness
// ! only applies to nodes, not edges
layout ="neato"
outputorder="edgesfirst" // why???
splines="true"
a[shape="point" pos="0,0!" color="blue"]
b[shape="point" pos="100,0!" color="green"]
c[shape="point" pos="50,50!" color="red"]
// "s" arrowhead must preceed "e" arrowhead, so swaped them
// BUT, "--" says non-directed graph, NO arrowheads, so they are deleted
// also need 4, 7, 11, ... points NOT including arrowhead points
// so added points (just guesses)
a -- b [pos="0,0 30,66 70,66 100,0"]
}
给出:
哇
我想以红点为控制点在蓝点和绿点之间创建一条样条曲线。
Graphviz 文档说:
- splines attribute,bool 或 string 类型,在 Graphs 上有效
- splineType 模式:
spline ( ';' spline )*
是 pos 属性的有效类型 - pos attribute 在边和节点上有效
我试过这张图
graph G{
layout ="neato" outputorder="edgesfirst" splines="true"
a[shape="point" pos="0,0!" color="blue"]
b[shape="point" pos="1,0!" color="green"]
c[shape="point" pos=" 0.5,0.5!" color="red"]
a -- b [pos="e,1,0 s,0,0 0.5,0.5!"]
}
然后 Windows 10 PowerShell :
neato.exe -Tsvg .\spline.dot > .\spline.svg
和
neato - graphviz version 2.49.3 (20211023.0002)
结果
实现此目标的正确方法是什么?
谢谢。
关闭,但是...
- !符号似乎只适用于节点(不是边缘)(记录不多,但请参阅:https://graphviz.org/docs/attr-types/point/ and https://graphviz.org/docs/attrs/pin/)
- 默认情况下,pos值单位是点(inch/72)。你的值太小了
- neato -n2 将使用您提供的节点和边值 (https://graphviz.org/faq/#FaqDotWithCoords)
- 所有边(不仅仅是曲线)都被定义为三次 B 样条,并由 1 + n*3 个点(n 是整数 >=1)(https://graphviz.org/docs/attr-types/splineType/)(即 4 或 7 或11 或 ...)
所以:
graph G{
// default units for pos values are in points (72/inch)
// multiplied by 100 out of laziness
// ! only applies to nodes, not edges
layout ="neato"
outputorder="edgesfirst" // why???
splines="true"
a[shape="point" pos="0,0!" color="blue"]
b[shape="point" pos="100,0!" color="green"]
c[shape="point" pos="50,50!" color="red"]
// "s" arrowhead must preceed "e" arrowhead, so swaped them
// BUT, "--" says non-directed graph, NO arrowheads, so they are deleted
// also need 4, 7, 11, ... points NOT including arrowhead points
// so added points (just guesses)
a -- b [pos="0,0 30,66 70,66 100,0"]
}
给出:
哇