我是使用 gnuplot 的新手,并且我遵循了这个问题,它根据我的需要绘制了数据。但是,我非常希望还包括误差线。我尝试通过添加最小和最大错误列来做到这一点,如下所示:
Broswer,Video,min,max,Audio,min,max,Flash,min,max,HTML,min,max,JavaScript,min,max
IE,30%,5,5,10%,5,5,25%,5,5,20%,5,5,15%,5,5
Chrome,20%,5,5,5%,5,5,35%,5,5,30%,5,5,10%,5,5
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用修改后的脚本进行绘图,如下所示:
set terminal pdf enhanced
set output 'bar.pdf'
set style data histogram
set style histogram cluster gap 1
set style fill solid border rgb "black"
set auto x
set yrange [0:*]
set datafile separator ","
plot 'data.dat' using 2:xtic(1) title col with yerrorbars, \
'' using 3:xtic(1) title col with yerrorbars, \
'' using 4:xtic(1) title col with yerrorbars, \
'' using 5:xtic(1) title col with yerrorbars, \
'' using 6:xtic(1) title col with yerrorbars
Run Code Online (Sandbox Code Playgroud)
根据我从阅读中了解到的内容,这也应该绘制错误栏,但我收到错误:
“plot2”,第 16 行:没有足够的列用于此样式
谷歌搜索这个错误告诉我它与第一列非数字有关。我尝试了一些建议,包括这个,但到目前为止没有任何效果。那么,有什么建议吗?谢谢。
此错误告诉您,yerrorbars
绘图样式需要多个列进行绘图(需要xtic(1)
特殊部分)。查看文档,您可以看到,您可以使用两列、三列或四列。我不会详细介绍,因为with yerrorbars
选择了全新的绘图样式,并且您根本没有得到任何直方图。
为了绘制聚类直方图,您必须添加errorbars
直方图的样式定义,当然您必须给出 yerror 值的列:
set style data histogram
set style histogram cluster gap 1 errorbars
set style fill solid border rgb "black"
set auto x
set yrange [0:*]
set datafile separator ","
plot 'data.dat' using 2:3:xtic(1) title col(2),\
'' using 5:6 title col(5), \
'' using 8:9 title col(8), \
'' using 11:12 title col(11), \
'' using 14:15 title col(14)
Run Code Online (Sandbox Code Playgroud)
或者,用更短的表示法
plot for [i=2:14:3] 'data.dat' using i:i+1:xtic(1) title col(i)
Run Code Online (Sandbox Code Playgroud)
如果您明确需要绘制最小值和最大值,则必须添加第三列。但最后两列是 ymin 和 ymax,而不是 delta 值。从您的数据文件错误来看,数据文件中的值是增量,因此绘图命令应该是:
plot for [i=2:14:3] 'data.dat' using i:(column(i) - column(i+1)):(column(i) + column(i+2)):xtic(1) title col(i)
Run Code Online (Sandbox Code Playgroud)