mardi 28 mars 2017

GNUPlot if statement on plot

I've a csv data file like this:

Sensor1;value;iteration
Sensor2;value;iteration
Sensor2;value;iteration
Sensor1;value;iteration
Sensor2;value;iteration

Can I plot two different lines in base of my 1st col value? one for Sensor1 and another for Sensor2 in same plot. Now I plot all data as follow:

set terminal jpeg
set output 'testimage.jpeg'
set   autoscale                        # scale axes automatically
unset log                              # remove any log-scaling
unset label                            # remove any previous labels
set xtic auto                          # set xtics automatically
set ytic auto                          # set ytics automatically
set datafile separator ";"
set xrange [1:10000]
set yrange [3000:5000]
plot "result_test_day_1.csv" using 5:3:(stringcolumn(1) eq "Sensor1"? $2:1/0) title "a" lc rgb "blue" with lines
plot "result_test_day_1.csv" using 5:3:(stringcolumn(1) eq "Sensor2"? $2:1/0) title "b" lc rgb "red" with lines

Aucun commentaire:

Enregistrer un commentaire