Affichage des articles dont le libellé est plot. Afficher tous les articles
Affichage des articles dont le libellé est plot. Afficher tous les articles

mardi 29 septembre 2015

Gnuplot by line (instead of columns)

In case you have some data not sorted by column (the easiet way to deal with gnuplot), and you want to plot it


Gnuplot definition: (file myplotrow.gpl)
set terminal x11 1 noraise
set autoscale
set grid
set xdata time
set timefmt "%Y-%m-%d_%H:%M:%S"
set format x "%m/%d\n%H:%M"
plot "data.dat" \
        using 1:(stringcolumn(2) eq "valAAA"? $3:1/0) title "A" lc rgb "blue",\
     "" using 1:(stringcolumn(2) eq "valBBB"? $3:1/0) title "B" lc rgb "red",\
     "" using 1:(stringcolumn(2) eq "valCCC"? $3:1/0) title "C" lc rgb "green",\
     "" using 1:(stringcolumn(2) eq "valDDD"? $3:1/0) title "D" lc rgb "orange",\
     "" using 1:(stringcolumn(2) eq "valEEE"? $3:1/0) title "E" lc rgb "purple",\
     "" using 1:(stringcolumn(2) eq "valFFF"? $3:1/0) title "F" lc rgb "violet"

pause 100
reread

That you can launch with :
gnuplot < myplotrow.gpl

Or, if you change the output in the first line :
set terminal postscript color


with :
gnuplot < myplotrow.gpl > myoutput.ps


Exemple values :
2015-09-24_10:00:00 valAAA 37.000
2015-09-24_10:00:00 valBBB 37.000
2015-09-24_10:00:00 valCCC 37.000
2015-09-24_10:00:00 valDDD 37.000
2015-09-24_10:00:00 valEEE 37.000
2015-09-24_10:00:00 valFFF 37.000
2015-09-24_13:30:00 valAAA 40.000
2015-09-24_13:30:00 valBBB 40.000
2015-09-24_13:30:00 valCCC 41.000
2015-09-24_13:30:00 valDDD 42.000
2015-09-24_13:30:00 valEEE 42.000
2015-09-24_13:30:00 valFFF 42.000
2015-09-25_02:00:00 valAAA 5.000
2015-09-25_02:00:00 valBBB 5.000
2015-09-25_02:00:00 valCCC 5.000
2015-09-25_02:00:00 valDDD 5.000
2015-09-25_02:00:00 valEEE 5.000
2015-09-25_02:00:00 valFFF 5.000
2015-09-25_03:30:00 valAAA 15.000
2015-09-25_03:30:00 valBBB 15.000
2015-09-25_03:30:00 valCCC 16.000
2015-09-25_03:30:00 valDDD 16.000
2015-09-25_03:30:00 valEEE 15.000
2015-09-25_03:30:00 valFFF 15.000
2015-09-25_05:30:00 valAAA 19.000
2015-09-25_05:30:00 valBBB 19.000
2015-09-25_05:30:00 valCCC 19.000
2015-09-25_05:30:00 valDDD 20.000
2015-09-25_05:30:00 valEEE 19.000
2015-09-25_05:30:00 valFFF 19.000
2015-09-25_06:00:00 valAAA 19.000
2015-09-25_06:00:00 valBBB 19.000
2015-09-25_06:00:00 valCCC 18.000
2015-09-25_06:00:00 valDDD 19.000
2015-09-25_06:00:00 valEEE 19.000
2015-09-25_06:00:00 valFFF 20.000
References :
  • Gnuplot terciary condition:
http://stackoverflow.com/questions/6564561/gnuplot-conditional-plotting-plot-col-acol-b-if-col-c-x
  • Colors
 http://gnuplot.sourceforge.net/demo/rainbow.html