Search code examples
gnuploterrorbar

Errorbars in gnuplot change the location of my points


My graph originally look like this:

without errorbars

But with error bars i get something like this:

with errorbars

This clearly isn't the same graph while in my description I just simply added "with errorbars".

My code is following :

plot "m20gnu.txt" using 1:2 title"Massa 20 g" pt 1 ps 0.8 lt 9,f(x) title  "Best passende rechte bij massa 20 g"

and with errorbars:

plot "m20gnu.txt" using 1:2 title"Massa 20 g" with errorbars pt 1 ps 0.8 lt 9,f(x) title  "Best passende rechte bij massa 20 g"

The data file looks like this:

0.16975     0.058823529     0.005   1

0.165       0.061728395     0.005   1

0.1415      0.047169811     0.005   1

0.13825     0.048543689     0.005   1

0.13975     0.045454545     0.005   1

0.1265      0.054945055     0.005   1

0.146791667 0.052083333     0.005   1

Does someone know what goes wrong here ? Thanks a lot already


Solution

  • When plotting without errorbars, you have using 1:2, which means: use the first column as x, and the second column as y value.

    Now, plotting with errorbars requires three values. So by using the same using statement again, you are missing one value. Depending on the selected plotting style, gnuplot tries to guess the third value, if you don't specify all. The documentation for yerrorbars says:

    2 columns: [implicit x] y ydelta
    3 columns: x y ydelta
    4 columns: x y ylow yhigh
    

    In your case

    plot "m20gnu.txt" using 1:2:3 with errorbars
    

    should work.