Eddy
Eddy

Reputation: 6861

Plot only (x,y) points with a specified z value

I have x,y,z data in 3 columns like this:

1  2  1
2  4  1
3  3  1
4  4  2
5  8  2
6  6  2

Say I only wanted to plot just (x,y) values where z=2 (i.e, just last 3 rows). How do I do that within gnuplot?

Upvotes: 1

Views: 857

Answers (1)

mgilson
mgilson

Reputation: 309929

plot 'datafile.dat' using 1:((column(3) == 2) ? column(2):NaN)

Note that you can also use the shorthand form: $3 instead of column(3). I just used the latter form because it is easier to read.

Upvotes: 1

Related Questions