9

I have the following file I want to plot using gnuplot bar graphs:

Function X X-ERROR Y Y-ERROR
A 1.311539 0.066268 1.000000 0.000000
(a1,b0)  1.325429 0.083437 1.010926 0.016710
(a.9,.b1)  1.134640 0.040017 1.276168 0.060281
(a.8,.b2)  1.078336 0.058529 1.346358 0.054645
(a.7,.b3)  1.035866 0.060660 1.318395 0.018087
(a.6,.b4)  0.982717 0.047363 1.196714 0.047427
(a.5,.b5)  0.962423 0.051994 1.127991 0.044731
(a.4,.b6)  0.953673 0.046014 1.139608 0.044726
(a.3,.b7)  0.948948 0.050462 1.169209 0.044333
(a.2,.b8)  0.941013 0.047166 1.198138 0.045844
(a.1,.b9)  0.929961 0.057801 1.328111 0.088813
(a0,b1)  0.966331 0.036079 3.289381 0.213192
B  1.000000 0.000000 3.321802 0.121290

I can manage to plot the graph perfectly using:

plot 'file.dat' using 4:xtic(1) title col, \\
        '' using 2:xtic(1) title col;

However I would like to use columns 3 and 5 to represent the interval of confidence that I always calculated. Any help?

Thanks!

2 Answers 2

12

Assuming you want to draw side-by-side bar charts with associated error bars, I would use the following:

set xrange [-0.5:12.75]
set xtic rotate by -45
set boxwidth 0.25
plot 'file.dat' using ($0-.05):4:5:xtic(1) with boxerrorbars title col, \\
     '' using ($0+0.25):2:3 with boxerrorbars title col

The idea is just to offset one of the two measures on the x-axis.

enter image description here

2
  • This is exactly what I wanted!! Lemme test it real quick!
    – Dynelight
    Jul 12, 2012 at 18:58
  • 1
    What does the '($0-.05)' in ($0-.05):4:5:xtic(1) represent? I know that '4' is telling the box to use the 4th column. '5' is telling the error bar to use the 5th column as the delta for the error bars. 'xtic(1)' is telling gnuplot to use the first column as the labels.
    – joseph
    Sep 30, 2015 at 23:15
0

I think this should do what you want (If I understand your plot correctly...)

plot 'test.dat' using (column(0)):4:3:xtic(1) w errorbars title col, \
     '' using (column(0)):2:5:xtic(1) w errorbars title col;
1
  • Hi thanks for your reply! Actually its not quite like that... I want something like this: csse.uwa.edu.au/programming/gnuplot_demos/errorbar/… Check out the set title "Demonstration of boxerrorbars" ... I have 2 different types of bars, and for each value, both bars must show. And for each bar, the error bar =) Is this more clear? Should I make a graphic and maybe that will be more representative?
    – Dynelight
    Jul 7, 2012 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.