Gnuplot Question

In gnuplot (I am using the W32 version, but it shouldn’t matter, and I have access to the UNIX version if necessary), is there a way to plot only certain data points from a file? Say I am plotting as follows:

plot ‘data.dat’ u 1:2

and I only want to use the first 10 values in both 1 and 2. How could I accomplish that, aside from parsing out into separate files?

… and I thought this was going to be about Guy Fawkes.

I don’t have a copy of GNUPlot handy, but can you specify the input through stdin? In which case you could do something like:

plot <yadda, yadda> | head -10 data.dat

[for the first 10 lines of data.dat]

On windows I imagine you’d need cygwin or something, but it would be straightforward on a typical UNIX-like environment.

AHEM Just uh… flip the two sides of the pipe there. I REALLY need to not post techie advice when I’m half-asleep. :smack:

Well he said he was using the Win32 version. According to my copy of GnuPlot (which looks interesting, thanks for making me open it), you can use sh - style backquoting for command subsitution, so under a sane shell environment,


load `head -10 filename` 

(from inside GnuPlot itself) should work. However, Windows doesn’t have a sane shell environment (sorry), so I have no idea whether one could achieve the same result under that OS.

The “every” function should do it, but I can’t say I’ve personally tried it:

plot ‘data.dat’ every ::::9: using 1:2

every syntax is:

This worked, thanks.