I have to plot several curve on a same graph. I necessarly need to use a for loop to do this. I would like to plot the 2 first curves with lines and the others with points. I am able to plot all the curves with lines or all the curves with points but not to change in the same for loop.
Here is the concerned part of my code:
set style line 1 lw 1 lc rgb "green"
set style line 2 lw 1 lc rgb "purple"
set style line 3 pt 1 ps 1.0 lc rgb "red"
set style line 4 pt 2 ps 1.0 lc rgb "red"
set style line 5 pt 3 ps 1.0 lc rgb "red"
plot for [i=1:words(FILES)] myDataFile(i) u (column(1)):((word(UTAUS_ch,i))) ls i title myTitle(i)
I would like to preface "ls i" with "w l" for the 2 first curves and "ls i" for the others. I tried to use a if statement by replacing "ls i" by "if (i < 2) {w l ls i} else {ls i}" but Gnuplot does not expect to find a if statement at this location.
Can someone help me ? Thank you, Martin
As mentioned here you probably cannot switch plotting styles within a
plot for
loop. So, either you do two separate loops, onewith points
and the otherwith lines
or you do one loopwith linespoints
and define all necessary parameters for points and lines as functions (to keep the plot command readable). As mentioned here,linewidth 0
is not zero but the thinnest possible line which is typically 1 pixel. To make the line disappear completely you have to uselinetype -2
.Code:
Result:
Addition:
In order to keep the plot command as short and clear as possible you could also define line styles and use it in the
plot for
command vials i
, with the same result as above.