Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot plotting data from a file up to some row

Tags:

plot

gnuplot

I have data in some text file which has let's say 10000 rows and 2 columns. I know that I can plot it easily by plot "filename.txt" using 1:2 with lines . What I want is however just plotting let's say the rows from 1000 to 2000 or any other reasonable selection. Is it possible to do that easily? Thank you very much in advance.

like image 891
jkt Avatar asked Mar 02 '12 16:03

jkt


People also ask

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.

Does gnuplot support multiple Y axes on a single plot?

5.9 Does gnuplot support multiple y-axes on a single plot? Yes.

What is gnuplot Splot?

splot is the command for drawing 3-d plots (well, actually projections on a 2-d surface, but you knew that). It can create a plot from functions or a data file in a manner very similar to the plot command. See plot (p. ) for features common to the plot (p. ) command; only differences are discussed in detail here.

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.


1 Answers

It appears that the "every" command in gnuplot is what you're looking for:

plot "filename.txt" every ::1000::2000 using 1:2 with lines 

Alternatively, pre-process your file to select the rows in which you are interested. For example, using awk:

awk "NR>=1000 && NR<=2000" filename.txt > processed.txt 

Then use the resulting "processed.txt" in your existing gnuplot command/script.

like image 143
Stuart Lange Avatar answered Nov 22 '22 22:11

Stuart Lange