Gnuplot command

gnuplot logo

3. String constants and string variables

N = 4
plot 'data.'.N title "Title for plot #".N
if ("A"."B" eq "AB") print "TRUE"

2. for

for [intvar = strat: end : {:increment}]
for [string in "A B C D"]
do for [...] {
}

Example:

plot for [filename in "A.dat B.dat C.dat"] filename using 1:2 with lines
plot for [basename in "A B C"] basename.".dat" using 1:2 with lines
set for [i = 1:10] style line i lc rgb "blue"
unset for [tag = 100:200] label tag
do for [t=0:50] {
    outfile = sprintf('animation/bessel%03.0f.png',t)
    set output outfile
    splot u*sin(v),u*cos(v),bessel(u,t/50.0) w pm3d ls 1
}

1. if

if (condition) { <commands>;
    <commands>
    <commands>
} else {
    <commands>
}

Example

if (str eq 'long') {
    set xrange [0:100];
} else {
    set xeange [0:1];
}

Reference

  1. gnuplot homepage
  2. Create scientific plots using gnuplot
  3. An Interactive Plotting Program