Donnerstag, 28. November 2013

gnuplot loop over datablocks

How to plot several datablocks with separate linestyles in one file?

In the following three datablocks are shown:

0.0 1.0
1.0 2.0
2.0 3.0

0.5 1.5
1.5 2.5
2.5 3.5

0.75 1.75
1.75 2.75
2.75 3.75

The first one e.g. can be addressed in gnuplot via:
plot 'datafile' every :::0::0

But to address all consecutively you need a loop the simplest way would be this loop over i=0,1,2:
plot for [i=0:2] 'datafile' every :::i::i w l ls i

There is also the possibility to use the do for loop with curly brackets {}:
 do for [i=0:3] {
 plot "datafile" ls i
} 

Keine Kommentare:

Kommentar veröffentlichen