nested - Elegant way to for loop several statements in gnuplot 4.6? -
i trying have plot statement loop on several couplets of functions plots. order of statements important because creates overdraw in right order.
#!/usr/bin/gnuplot -persist datfile="overdraw.dat" num=3 skip=40 set table datfile g(x,t)=exp(-x**2+{0,1}*2*t*x) set samples 501 plot [-2:2][0:5] [ii=0:num] real(g(x,ii)) unset table xspeed=0.1 yspeed=0.3 ## works creates overdraw in wrong order #plot [-2:2] \ # [ii=0:num] datfile index ii u ($1+xspeed*ii):($2-yspeed*ii) not w l lt ii lw 8 \ #, [ii=0:num] datfile index ii every skip u ($1+xspeed*ii):($2-yspeed*ii) not w p lt ii pt 7 ps 4 \ # set macro ## works cumbersome plotstring="nan not" [ii=0:num] { plotstring=plotstring.sprintf(", \"%s\" index %i u ($1+xspeed*%i):($2-yspeed*%i) not w l lt %i lw 8", datfile, ii, ii, ii, ii) plotstring=plotstring.sprintf(", \"%s\" index %i every skip u ($1+xspeed*%i):($2-yspeed*%i) not w p lt %i pt 7 ps 4", datfile, ii, ii, ii, ii) } plot [-2:2] @plotstring ## doesn't work because loop applies first statement #plotboth='datfile index ii u ($1+xspeed*ii):($2-yspeed*ii) not w l lt ii lw 8\ #, datfile index ii every skip u ($1+xspeed*ii):($2-yspeed*ii) not w p lt ii pt 7 ps 4' #plot [-2:2] [ii=0:num] @plotboth ## gives error message plot [-2:2] [ii=0:num] { \ datfile index ii u ($1+xspeed*ii):($2-yspeed*ii) not w l lt ii lw 8\ , datfile index ii every skip u ($1+xspeed*ii):($2-yspeed*ii) not w p lt ii pt 7 ps 4 \ } as can see, made work in right order appending string holding plot statement. nice, however, able put brackets around plot statements indicated @ end of example.
submitting several plot/replot statements seems not option, creates pages in in terminals (e.g. postscript). regard multiplot cumbersome, too. perhaps there elegant syntax have overlooked?
instead of having 2 commands, 1 lines , 1 points, i'd suggest 1 command line points, - because there many data-points - skipping in plot (as intend skip variable).
based on dataset, used following code generate plot:
plot [-2:2] [ii=0:num] datfile index ii u ($1+xspeed*ii):($2-yspeed*ii) \ not w lp lt ii lw 8 pt 7 pi skip ps 4 i used w lp command (which short with linespoints) have line and points, , pi skip (which short pointinterval skip) skip 40 datapoints between symbols. more information on linespoints , pointinterval can found in documentation.
Comments
Post a Comment