【问题标题】:How to plot a closed polygon with a spline in gnuplot?如何在 gnuplot 中用样条线绘制闭合多边形?
【发布时间】:2020-04-12 21:16:28
【问题描述】:

我尝试使用 gnuplot 围绕多边形创建样条曲线(参见图片1)。不幸的是没有成功。 所有“平滑”变体都不能解决问题,因为它们中的大多数都对 x 值进行排序,而“贝塞尔”不是样条曲线。 还有其他想法吗? Spline was created with LibreCalc

【问题讨论】:

    标签: gnuplot polygon spline


    【解决方案1】:

    gnuplot 的开发版本在 3D 绘图中使用通用路径跟踪样条。这接近您的要求,但有一些限制

    • 为了触发路径跟踪样条,点不能位于平面内(下面using 规范中复杂的第三个条目只是将点移出 xy 平面)。
    • 您不会在路径开始/结束的连接点处进行四舍五入
    • 此绘图模式不在已发布的 gnuplot 版本中
    • 仅适用于splot,不适用于splot

    例子

     unset key
     set view map
     splot 'spline.dat' using 1:2:($1==1?0:$0)  smooth cspline with lines lt 1, \
           '' using 1:2:($1==1?0:$0)  with points pt 7 lt 1
    

    【讨论】:

      【解决方案2】:

      18 个月后

      由于我看到这个问题仍在获得意见,我正在添加一个更新的答案。第一个答案中提到的限制现在已被删除。 Gnuplot 5.5(开发版)在 2D 和 3D 绘图中支持新的平滑选项smooth path

      这是文档部分:

      gnuplot> help smooth path
      
       The `smooth path` option generates cubic splines to fit points in the order
       they are presented in the input data; i.e. they are not first sorted on x.
       This generates a smooth spline through a closed curve or along a trajectory
       that contains loops. This smoothing mode is supported for both 2D and 3D
       plot commands.  As always, a separate curve is created for each set
       of points in the input file, where a blank line separates the sets.
       Plotting `smooth path with filledcurves closed` will guarantee that each set
       of points creates a closed curve.  Plotting `smooth path with lines` will
       generate a closed curve if the first and last points in the set overlap,
       otherwise it will create an open-ended smooth path.
      

      这是a from the online collection的一部分:

      $LOOP << EOD
      1.5 0.5
      2.5 0.5
      3   1.0
      3.5 1.5
      4.0 3.5
      3.6 4.5
      3.0 2.5
      4   1.5
      5   1.5
      EOD
      
      plot $CURVES using 1:2 with points pt 7 ps 2 lc "steelblue" title "original points", \
                '' using 1:2 smooth path with lines lt 3 title "smooth path with lines", \
           $LOOP using 1:2 with points pt 7 ps 2 lc "steelblue" notitle, \
              '' using 1:2 smooth path with lines lt 3 notitle
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-09-05
        • 2010-09-24
        • 2017-12-08
        • 1970-01-01
        • 2017-07-25
        • 2014-04-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多