2

Let's suppose my dataset is like this:

0 0.3
1 0.12
2 0.4
3 0.6
4 0.9
...
10 0.23
11 0.6
...
20 0.34
21 0.4
...

and I'd like to plot values of both columns only if $1 % 10 == 0, i.e., (0,0.3), (10,0.23), (20,0.34) and so on... Now, I've written the following conditional script:

plot "data.csv" using 1:(int($1)%10==0?$2:0/0) title 'r=1' with linespoints linewidth 3 linecolor rgb 'blue'

The problem is that lines are not shown, but only points.

enter image description here

This is because, for all rows where the condition is not satisfied, the corresponding value is undefined. Anyway, what I need is quite different; I want those specific values to be just ignored, not to set to undefined. Is there a way to do that just using gnuplot (not awk and so on)?

1 Answer 1

3

In case you have all intermediate steps, i.e., full data for number (which is suspect based on your axis labelled iterations), you best use the every option

plot "data.csv" every 10 with linespoints

Otherwise, I would use awk inside your script for simplicity

plot "<awk '$1%10==0' data8" with linespoints

The probably with your original script, is that the points are shown, but with value infinity. It is a feature that these lines are not shown.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, Bernhard. I didn't know the "every" option; it works as I want!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.