Pergunta

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)?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top