Search code examples
gnuplot

Gnuplot: plot data with every option


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? that is, the points (2, 2.0), (4, 4.0) (6, 6.0).

Thanks


Solution

  • You can define the start point, as described in gnuplot documentation about every. Try something like:

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