Discussion:
Plot data using every
(too old to reply)
s1291
2019-10-30 14:38:18 UTC
Permalink
Hello,
I have a single block of data points in a file: data.dat, For example let's consider the following example of data.dat file:

1 1.0
2 2.0
3 3.0
4 4.0
5 5.0
6 6.0
7 7.0

To plot only the points with odd x value:

plot 'data.dat' u 1:2 every 2 w lp

This will plot the points (1, 1.0), (3, 3.0), (5, 5.0), (7, 7.0).

What if I want to plot the points with even x value using 'every' keyword? that is, the points (2, 2.0), (4, 4.0) (6, 6.0).

Thanks
Hans-Bernhard Bröker
2019-10-30 19:19:26 UTC
Permalink
Post by s1291
What if I want to plot the points with even x value using 'every' keyword? that is, the points (2, 2.0), (4, 4.0) (6, 6.0).
Then you continue reading the documentation of the 'every' option, which
you already found.
s1291
2019-10-30 19:29:14 UTC
Permalink
Post by Hans-Bernhard Bröker
Post by s1291
What if I want to plot the points with even x value using 'every' keyword? that is, the points (2, 2.0), (4, 4.0) (6, 6.0).
Then you continue reading the documentation of the 'every' option, which
you already found.
Thank you for your reply.
I've read the documentation but I don't see how to do that.
Could you just post it?
Thanks
Karl Ratzsch
2019-10-31 07:38:25 UTC
Permalink
Post by s1291
Post by Hans-Bernhard Bröker
Post by s1291
What if I want to plot the points with even x value using 'every' keyword? that is, the points (2, 2.0), (4, 4.0) (6, 6.0).
Then you continue reading the documentation of the 'every' option, which
you already found.
Thank you for your reply.
I've read the documentation but I don't see how to do that.
Read again ;) (under "help every")

plot 'file' every {<point_incr>}
{:{<block_incr>}
{:{<start_point>}
{:{<start_block>}
{:{<end_point>}
{:<end_block>}}}}}

Your default start_point is zero. You just set it to "1":

plot dataf every 2::1

Alternative (plot even data, not even point/line numbers)

plot dataf us ($1 % 2 == 0 ? $1 : NaN):2

Loading...