【问题标题】:How to use Gnuplot to print 3D plots (splot) with error bars and different linespoints如何使用 Gnuplot 打印带有误差线和不同线点的 3D 图(splot)
【发布时间】:2020-10-08 00:03:52
【问题描述】:

使用Gnuplot 绘制带有splot 的3D 图表和使用zerror 的错误不允许我们有不同的线和点。 Here 是示例。我想将splot 与误差线一起使用,并且仍然通过不同的点来区分线条。就像提到here

with 的操作也和 plot 一样,只是 可用于 splot 的绘图样式仅限于线、点、 线点、点和脉冲; plot 的误差线功能 不适用于 splot。

Gnuplot 中是否有针对此问题的另一种解决方案?

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    正如您所注意到的,似乎没有用于在 3D 中绘制误差线的直接绘图样式。可以操作输入数据以伪绘制线条样式的误差线。

    示例脚本:

    $inputdata <<EOD
    # x y z zlow zhigh
    1 1 1 0 2
    2 1 2 1 3
    3 1 3 2 4
    4 1 4 3 5
    5 1 5 4 6
    
    
    1 2 5 1 7
    2 2 4 1 7
    3 2 3 1 7
    4 2 2 1 7
    5 2 1 1 7
    
    
    1 3 3 1 4
    2 3 3 2 5
    3 3 3 3 6
    4 3 3 2 5
    5 3 3 1 4
    EOD
    
    # construct errorbar's line segments data
    set table $first
    plot $inputdata using 1:2:4:($1-0.1):4:5:0 with table
    set table $second
    plot $inputdata using 1:2:5:($1+0.1):4:5:0 with table
    unset table
    
    # summarize data into data block $errbars
    stats $inputdata using 0 nooutput
    set print $errbars 
    do for [i=1:STATS_records] {
      print $first[i]
      print $second[i]
      print ""
      print ""
    }
    set print
    
    set xrange [0:6]
    set yrange [0:4]
    
    set key noautotitle
    
    splot $inputdata using 1:2:3:2 with linespoints pt 7 lc variable, \
          $errbars   using 1:2:3:2 with lines lc variable, \
          $errbars   using 4:2:5:2 with lines lc variable, \
          $errbars   using 4:2:6:2 with lines lc variable
    
    pause -1
    

    它使用数据点和误差范围的逐行数据 (x,y,z,zlow,zhigh) 作为输入来构建数据以绘制误差线和晶须。完成后,我们可以用线条样式绘制误差线的每个部分。

    结果:


    这是另一个使用矢量样式的解决方案,实际上比上面的脚本简单得多。

    示例脚本:

    $inputdata <<EOD
    # x y z zlow zhigh
    1 1 1 0 2
    2 1 2 1 3
    3 1 3 2 4
    4 1 4 3 5
    5 1 5 4 6
    
    
    1 2 5 1 7
    2 2 4 1 7
    3 2 3 1 7
    4 2 2 1 7
    5 2 1 1 7
    
    
    1 3 3 1 4
    2 3 3 2 5
    3 3 3 3 6
    4 3 3 2 5
    5 3 3 1 4
    EOD
    
    set xrange [0:6]
    set yrange [0:4]
    
    unset key
    set style arrow 3 heads size 0.05,90 lc variable
    
    splot $inputdata using 1:2:3:2 with linespoints pt 7 lc variable, \
          $inputdata using 1:2:4:(0):(0):($5-$4):2 with vectors arrowstyle 3 
    
    pause -1
    
    

    谢谢。

    【讨论】:

    • 你是对的。看起来不是很清楚。还是谢谢!
    • 我添加了另一个使用矢量样式的解决方案,它更简单。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-28
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    • 1970-01-01
    相关资源
    最近更新 更多