gpt4 book ai didi

gnuplot - gnuplot 中带有错误条的聚类条形图

转载 作者:行者123 更新时间:2023-12-04 02:07:33 26 4
gpt4 key购买 nike

我刚开始使用 gnuplot,我已经关注了 this question它根据我的需要绘制数据。但是,我非常想也包括错误栏。我尝试通过添加最小和最大错误列来做到这一点,如下所示:

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

然后我尝试使用修改后的脚本进行绘制:

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

据我阅读的理解,这也应该绘制错误栏,但我得到了错误:

"plot2", line 16: Not enough columns for this style

谷歌搜索这个错误告诉我它与第一列是非数字有关。我尝试了一些建议,包括 this one ,但到目前为止没有任何效果。那么,有什么建议吗?谢谢。

最佳答案

此错误告诉您,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)

或者,用更短的表示法

plot for [i=2:14:3] 'data.dat' using i:i+1:xtic(1) title col(i)

enter image description here

如果您明确需要绘制最小值和最大值,则必须添加第三列。但是最后两列是 ymin 和 ymax 而不是增量值。从你的数据文件错误来看,数据文件中的值是增量,所以绘图命令应该是:

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)

关于gnuplot - gnuplot 中带有错误条的聚类条形图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41942693/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com