【问题标题】:How to draw a spline curve between 2 points with a control points with graphviz?如何使用graphviz在2点之间绘制带有控制点的样条曲线?
【发布时间】:2022-01-19 12:36:28
【问题描述】:

我想在蓝点和绿点之间创建一条样条曲线,以红点为控制点。

Graphviz 文档说:

  1. splines attribute,bool 或 string 类型,在 Graphs 上有效
  2. splineType 与模式:spline ( ';' spline )* 是 pos 属性的有效类型
  3. 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)

结果

实现这一目标的正确方法是什么?

谢谢。

【问题讨论】:

  • 这是最终目标,还是更大项目的一部分?
  • @sroush,它确实是一个更大项目的一部分。阅读文档时似乎可以,但到目前为止无法正确使用它并且我没有找到任何示例。
  • DIY 样条线是一种痛苦,但可行 - 尽管完全自动化将是一种超级痛苦。要与“普通”点图结合,请考虑从主图的“点 -Tdot”开始

标签: graphviz spline


【解决方案1】:

关闭,但是...

所以:

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"]   
}

给:

【讨论】:

  • 谢谢!关于 outputorder="edgesfirst" ,如果您对此进行注释并重新渲染,您会看到边缘覆盖了蓝色和绿色点,当然,您可能需要稍微放大一下才能注意到。
猜你喜欢
  • 2019-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-29
  • 2017-02-18
  • 1970-01-01
  • 1970-01-01
  • 2014-12-16
相关资源
最近更新 更多