在Gnuplot的多轴绘图中显示错误条

在Gnuplot的多轴绘图中显示错误条,gnuplot,histogram,errorbar,Gnuplot,Histogram,Errorbar,我有一个数据集(show errorbar.dat),其中包含: 模型误差 苹果-4.6-128.9538 4.0 华为-5.2-176.6343 5.3 一个Pro-5.2-118.1106 3.2 #!/usr/bin/gnuplot #set terminal pdfcairo enhanced color font 'Helvetica,12' linewidth 0.8 set terminal png set output 'BrandError.png' set boxwidth

我有一个数据集(show errorbar.dat),其中包含:

模型误差

苹果-4.6-128.9538 4.0

华为-5.2-176.6343 5.3

一个Pro-5.2-118.1106 3.2

#!/usr/bin/gnuplot
#set terminal pdfcairo enhanced color font 'Helvetica,12' linewidth 0.8
set terminal png
set output 'BrandError.png'

set boxwidth 1.0 relative
set bmargin 5
set style fill solid border -1
set xtic rotate by -45 scale 0
#set auto x

set style line 81 lt 0 lc rgb "#808080" lw 0.5

set grid xtics
set grid ytics
set grid mxtics
set grid mytics
set grid back ls 81

set arrow from graph 0,first -4.6 to graph 1, first -4.6 nohead lw 2 lc rgb "#000000" front

set border 11
set border lw 2.0

set xtics font ",11"
set ytics font ",14"
set tics out
set ytics nomirror
set y2tics
set y2tics font ",14"


set mxtics 10
set mytics 2
set my2tics 2

set yrange [-10:0]
set y2range [-260:0]

set key left bottom

set y2label offset -2
set ylabel offset 2

set ylabel 'DE' tc rgb "red"
set y2label 'IE' tc rgb "green"

set style data histograms
set style histogram cluster gap 2

set linetype 2 lc rgb 'red'
set linetype 3 lc rgb 'yellow'
set linetype 4 lc rgb 'green'


plot 'show-errorbars.dat' using 2 ti 'DE' lc 2 axis x1y1, '' u 3:xticlabels(1) ti 'IE' lc 4 axis x1y2
set output
我想绘制一个柱状图,比较DE与IE之间的差异,并显示IE值的误差条(第4列中的数据)。


请提供有关如何进行此操作的任何帮助。

有一种不同的柱状图样式正好用于此目的
设置样式直方图错误条间距2{lw W}
。 以下是文档中的帮助部分:

The `errorbars` style is very similar to the `clustered` style, except that it
requires additional columns of input for each entry. The first column holds
the height (y value) of that box, exactly as for the `clustered` style.
      2 columns:        y yerr          bar extends from y-yerr to y+err
      3 columns:        y ymin ymax     bar extends from ymin to ymax
The appearance of the error bars is controlled by the current value of
`set errorbars` and by the optional <linewidth> specification.

正是出于这个目的,有一种不同的柱状图样式
设置样式直方图错误条间距2{lw W}
。 以下是文档中的帮助部分:

The `errorbars` style is very similar to the `clustered` style, except that it
requires additional columns of input for each entry. The first column holds
the height (y value) of that box, exactly as for the `clustered` style.
      2 columns:        y yerr          bar extends from y-yerr to y+err
      3 columns:        y ymin ymax     bar extends from ymin to ymax
The appearance of the error bars is controlled by the current value of
`set errorbars` and by the optional <linewidth> specification.

嗨,伊桑,你能给我再详细解释一下吗?当然可以。请参阅更新的答案。嗨@Ethan,我尝试了新的plot命令,它似乎通过错误条偏移来工作。嗨@Ethan,我尝试了新的plot命令,它似乎工作,但错误条偏移。我在第一次尝试时也得到了补偿。这时我意识到数据文件中存在一个额外的行导致了混乱。添加
set-key-autotitle-columnhead
修复了偏移量。嗨,伊桑,你能给我详细解释一下吗?当然。请参阅更新的答案。嗨@Ethan,我尝试了新的plot命令,它似乎通过错误条偏移来工作。嗨@Ethan,我尝试了新的plot命令,它似乎工作,但错误条偏移。我在第一次尝试时也得到了补偿。这时我意识到数据文件中存在一个额外的行导致了混乱。添加
set key autotitle列头
修复了偏移量。