Gnuplot图例错误栏符号垂直

时间:2015-05-13 15:15:16

标签: gnuplot legend

如何使用gnuplot使图例错误符号垂直而不是水平? set key vertical未达到预期效果:

set key vertical
plot "file.txt" using 1:2:3 with yerrorbars

1 个答案:

答案 0 :(得分:1)

感谢comment Christoph提出的想法。

正如问题评论中Christoph所示,没有内置方法可以更改图例中errorbars的方向:xerrorbarsyerrorbars并且xyerrorbars都是水平的。

Horizontal error bars in Gnuplot, the default in the legend

要获得垂直误差线,可以考虑禁用图例(unset key)并使用set labelset arrow手动绘制图例。误差条可以绘制为具有两个头部的箭头,其形状为垂直于箭头线的线。这看起来像是:

# definition of arrow styles and line styles here, something like:
#   set style line 41 lc rgb "#cccccc" lt 1 lw 1 ps 0.5 pt 6
#   set style arrow 1 heads size screen 0.008,90 ls 1
#   ...

set label "class 1" at graph 0.7, graph 1                         # label
set arrow as 1  from graph 1, graph 0.97  to graph 1, graph 1.02  # arrow
set label ""    at   graph 1, graph 0.99  point ls 1              # dot

set label "class 2" at graph 0.7, graph 0.8                       # label
set arrow as 2  from graph 1, graph 0.77  to graph 1, graph 0.82  # arrow
set label ""    at   graph 1, graph 0.79  point ls 2              # dot

Manually drawn vertical error bars

你当然可以调整条的长度,它们的位置,点大小,垂直线长度......