Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot with errorbars plotting

Tags:

plot

gnuplot

The data in my "file.txt" file are as in the following (sample row shown)

31 1772911000 6789494.2537881

Note that the second column is the mean and the third is the standard deviation of my input sample. So, for the error bar, I would need the bar at the x axis value 31, with the error bar start at (second column value)-(third column value), and end at (second column value)+(third column value). I tried the following:

plot "file.txt" using ($1-$2):1:($2+$1) with errorbars

but the result is inappropriate. Any help?

like image 333
user506901 Avatar asked May 21 '12 11:05

user506901


People also ask

Does gnuplot support multiple Y axes on a single plot?

5.9 Does gnuplot support multiple y-axes on a single plot? Yes. 2D plots can have separate x axes at the bottom (x1) and top (x2), and separate y axes at the left (y1) and right (y2).

How use gnuplot to plot data from a file?

To plot functions simply type: plot [function] at the gnuplot> prompt. Discrete data contained in a file can be displayed by specifying the name of the data file (enclosed in quotes) on the plot or splot command line. Data files should have the data arranged in columns of numbers.

Is gnuplot easy?

Running gnuplot is easy: from a command prompt on any system, type gnuplot. It is even possible to do this over a telnet or ssh connection, and preview the graphs in text mode!

What files can gnuplot open?

Gnuplot can read binary data files. However, adequate information about details of the file format must be given on the command line or extracted from the file itself for a supported binary filetype. In particular, there are two structures for binary files, a matrix binary format and a general binary format.


2 Answers

You need x:y:err, so try

plot "file.txt" using 1:2:3 with yerrorbars

yerrorbars

You may instead want candlesticks. These are generally a box with error bars extending out of the top and bottom, but setting the mins and maxes the same should give you boxes of the required size:

plot "file.txt" using 1:($2-$3):($2-$3):($2+$3):($2+$3) with candlesticks

candlesticks

like image 123
5 revs, 2 users 58% Avatar answered Oct 15 '22 06:10

5 revs, 2 users 58%


you can also try:

plot "file.txt" using 1:2:($2-$3):($2+$3) with errorbars

($2-$3) is y error bar low value, and ($2+$3) is y error bar high value

However, I think that you should use standard error = standard deviation / square root (sample size), instead of standard deviation, to compute error bars.

like image 29
hmitcs Avatar answered Oct 15 '22 07:10

hmitcs