I wanted to be able to generate Gnuplot images of my SPH results for an arbitrary number of state files. Thanks to the magic of shell scripting, I can!
Here is a bash script:
#! /bin/bash
ls sphstate.* > list
for i in `cat list` ; do
echo item: $i
sed -e "s/INPUTFILE/$i/" -e "s/OUTPUTFILE/$i/" sphplot.plt | gnuplot
done
Here is a gnuplot script:
set term png small
set output "OUTPUTFILEtemp.png"
plot "INPUTFILE" using 1:7 title "temperature"
Here are a few URLS:
Sed tutorial
Gnuplot IFAQs (recommended)
Bash scripting guide
karolle said
hi there,
thanks for that script. the only problem that remained is that gnuplot prints the key/legend on top of each other if i plot a number of lines in one graph.
ac12 said
Try something like this:
plot INPUTFILE using 1:2:($3*25):($4*25) axes x1y1 ti "v" with vectors lt rgb "red" \
,INPUTFILE using 1:2 axes x1y1 ti "r" with points 7 \
,INPUTFILE using 1:10 axes x2y2 ti "density" with points 3
I usually find gnuplot does OK with the legend for a few multiple lines – it can sometimes stumble on more complex layouts though.