Reputation: 155
Normally the xrange and yrange are adjusted to fit the largest and smallest value in the datafile, when plotting according to
plot "my_file.dat" u 1:2
Suppose I want to apply a cutoff to the y-values, so that I only include the points whose y-value is larger than, say 1. If I do
plot "my_file.dat" u 1:($2>1?$2:NaN)
I indeed select only those points. The problem, however, is that the xrange is still adjusted to the range of column 1 of the entire datafile, rather than to only those points which are actually plotted. How can I fix this? My gnuplot version is 5.2.
Upvotes: 2
Views: 200
Reputation: 3055
You also have to filter the undesired x-values in a similar way:
plot 'my_file.dat' u ($2 > 1 ? $1 : NaN):($2 > 1 ? $2: NaN)
If you want to draw a line between these points, a different way of filtering is necessary: see Plotting lines with missing datapoints for multidimensional data
Upvotes: 3