【问题标题】:Gnuplot Bar chart with error bars带有误差线的 Gnuplot 条形图
【发布时间】:2014-07-21 18:17:05
【问题描述】:

我有以下数据

Name   Value of the bar   Confidence interval
A      0.62               [0.59 0.63]
B      0.64               [0.54 0.72]
C      0.51               [0.46 0.67]
D      0.33               [0.25 0.36]

我尝试将其绘制为条形图,用 A、B、C 和 D 标记每个条形图,并带有误差条形图。

通过使用

plot "my.dat" using 1; with boxes我只得到一个条形图。有人可以帮我吗?

【问题讨论】:

    标签: gnuplot bar-chart axis-labels


    【解决方案1】:

    如果您还需要误差线,则必须添加第二个具有yerrorbars 绘图样式的绘图。括号在数据文件中不是很方便,所以我用sed 命令删除它们:

    set style fill solid
    set boxwidth 0.8
    set yrange [0:*]
    unset key
    plot "< sed 's/[][]//g' my.dat" using 0:2:xtic(1) with boxes, \
         '' using 0:2:3:4 with yerrorbars lc rgb 'black' pt 1 lw 2
    

    【讨论】:

    • 谢谢!这就是我想要的。
    • 有没有可能改变条的颜色?让每个条形都有不同的颜色或图案(用点或线填充)
    • 是的,您可以使用例如lc variable 根据某个值(可能是行号)为条形着色:plot "&lt; sed 's/[][]//g' my.dat" using 0:2:0:xtic(1) lc variable with boxes