Gnuplot:如何将yerrorbars添加到使用“ newhistogram”绘制的多个群集直方图绘制的直方图中?

时间:2019-07-08 16:16:24

标签: gnuplot bar-chart histogram errorbar

我已经将一组数据簇绘制到直方图的同一图中。由于我有几组数据集,因此我使用了实用的“ newhistogram”命令。它工作正常,但我还没有找到如何添加yerrorbars的方法?我很高兴有人熟悉如何在“ newhistogram”命令中添加errobar。

我已经尝试将简单的命令“ w yerrorbars”(包括相关引用)添加到数据文件的列,但是该图仅包含yerrorbars(包括中间的均值),但不再显示条形图。

...
set datafile separator ','
...
set style data histogram
set style histogram errobars linewidth 1
set bars 0.5

plot newhistogram "Multi-crew ops", 'example.dat' index 0 u 3:xtic(2) t 'Departure', 'example.dat' index 0 u 5:xtic(2) t 'Cruise', 'example.dat' index 0 u 7:xtic(2) t 'Arrival', \
    newhistogram "Reduced-crew ops", 'example.dat' index 1 u 3:xtic(2) t 'Departure', 'example.dat' index 1 u 5:xtic(2) t 'Cruise' , 'example.dat' index 1 u 7:xtic(2) t 'Arrival', \
    newhistogram "Acceptance of crewing-ops", 'example.dat' index 2 u 9:xtic(1) axes x1y2 t 'All phases'

这没有解决: ...

plot newhistogram "Multi-crew ops", 'example.dat' index 0 u 3:4:xtic(2) t 'Departure' w yerrorbars, ...

这也不可行:

set datafile separator ','

set style data histogram
set bars 0.5
set style histogram errobars linewidth 1

plot newhistogram "Multi-crew ops", 'example.dat' index 0 u 3:4:xtic(2) t 'Departure', 'example.dat' index 0 u 5:6:xtic(2) t 'Cruise', 'example.dat' index 0 u 7:8:xtic(2) t 'Arrival', \
    newhistogram "Reduced-crew ops", 'example.dat' index 1 u 3:4:xtic(2) t 'Departure', 'example.dat' index 1 u 5:6:xtic(2) t 'Cruise' , 'example.dat' index 1 u 7:8:xtic(2) t 'Arrival', \
    newhistogram "Acceptance of crewing-ops", 'example.dat' index 2 u 9:10:xtic(1) axes x1y2 t 'All phases'

2 个答案:

答案 0 :(得分:0)

您显示的命令的问题在于,每个条形图仅提供一列输入数据(y值)。为了添加错误栏,您需要第二个输入列,其中包含delta-y值。例如您有

   'example.dat' index 0 u 3:xtic(2) t 'Departure'

您应该改为

   'example.dat' index 0 u 3:N:xtic(2) t 'Departure'

其中N是保存错误值的列。如果要从函数计算错误而不是从输入列读取错误,则看起来像这样

   'example.dat' index 0 u 3:(func(something)):xtic(2) t 'Departure'

答案 1 :(得分:0)

最后,我找到了一个如何将错误栏集成到gnuplot的newhistogram命令中的答案。样式必须设置为直方图簇。甚至还可以使用颜色等:

docker@mildevdcr01:~$ helm version
Client: &version.Version{SemVer:"v2.14.1", 
GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.0", 
GitCommit:"05811b84a3f93603dd6c2fcfe57944dfa7ab7fd0", GitTreeState:"clean"}