Automating gnuplot

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

Advertisements

2 Comments »

  1. 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.

  2. 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.

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: