Wednesday, 15 February 2012

Loop structure inside gnuplot? -



Loop structure inside gnuplot? -

is there way iteratively retrieve info multiple files , plot them on same graph in gnuplot. suppose have files data1.txt, data2.txt......data1000.txt; each having same number of columns. write like-

plot "data1.txt" using 1:2 title "flow 1", \ "data2.txt" using 1:2 title "flow 2", \ . . . "data1000.txt" using 1:2 title "flow 6"

but inconvenient. wondering whether there way loop through plot part in gnuplot.

there sure (in gnuplot 4.4+):

plot [i=1:1000] 'data'.i.'.txt' using 1:2 title 'flow '.i

the variable can interpreted variable or string, like

plot [i=1:1000] 'data'.i.'.txt' using 1:($2+i) title 'flow '.i

if want have lines offset each other.

type help iteration @ gnuplot command line more info.

also sure see @dariop's reply do for syntax; gives closer traditional for loop.

gnuplot

No comments:

Post a Comment