Gnuplot Bar chart with error bars

旧城冷巷雨未停 提交于 2021-02-10 05:27:06

问题


I have the following data

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]

I tried to plot it as a bar chart with A,B,C and D labeling each bar and with and error bar.

By using

plot "my.dat" using 1; with boxes I only get a bar chart. Can someone help me?


回答1:


If you also want errorbars, you must add a second plot with the yerrorbars plotting style. The brackets aren't very handy in the data file, so I remove them with a sed command:

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

enter image description here



来源:https://stackoverflow.com/questions/24871941/gnuplot-bar-chart-with-error-bars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!