and I want to plot only the lines where the first value is "a", is it possible with gnuplot?
I need something like
plot 'file.dat' using 2:($1==a ? $3 : 1/0) w lp
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What does it mean "doesn't work"? Do you get an error message, a wrong plot?
If I try the example you gave:
file mmm.dat with content
a 1 2 3
a 4 5 6
b 6 7 9
b 1 2 3
and
plot 'mmm.dat' using (stringcolumn(1) eq "b" ? $3 : 1/0):(stringcolumn(1) eq "a" ? $3 : 1/0) w lp
I get the message "warning: Skipping data file with no valid points", which is obvious, because with this data one of the two expressions always evaluates to 1/0, so all points are invalid.
Christoph
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Think you Christoph for your effort :)
In fact, I get this error 'x range is invalid' and I undersatand that the coordinates of the points we want to plot must be in the same line. So, I managed to change the data file to solve my problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a data file that looks like this:
a 1 2 3
a 4 5 6
b 6 7 9
b 1 2 3
and I want to plot only the lines where the first value is "a", is it possible with gnuplot?
I need something like
plot 'file.dat' using 2:($1==a ? $3 : 1/0) w lp
Use
plot 'file.dat' using 2:(stringcolumn(1) eq "a" ? $3 : 1/0)
Christoph
Awsome, it works think you
well, it worked for the first case, but when I try this
plot 'mmm.dat' using (stringcolumn(1) eq "b" ? $3 : 1/0):(stringcolumn(1) eq "a" ? $3 : 1/0) w lp
it doesn't work anymore
What does it mean "doesn't work"? Do you get an error message, a wrong plot?
If I try the example you gave:
file mmm.dat with content
a 1 2 3
a 4 5 6
b 6 7 9
b 1 2 3
and
plot 'mmm.dat' using (stringcolumn(1) eq "b" ? $3 : 1/0):(stringcolumn(1) eq "a" ? $3 : 1/0) w lp
I get the message "warning: Skipping data file with no valid points", which is obvious, because with this data one of the two expressions always evaluates to 1/0, so all points are invalid.
Christoph
Think you Christoph for your effort :)
In fact, I get this error 'x range is invalid' and I undersatand that the coordinates of the points we want to plot must be in the same line. So, I managed to change the data file to solve my problem.