Results 1 to 1 of 1
Hello Forum,
after a lot of searching I found a bash script which makes a list of data files and passes them one by one to a gnuplot script. The ...
- 10-17-2009 #1Just Joined!
- Join Date
- Aug 2009
- Posts
- 6
bash script for automating gnuplot
Hello Forum,
after a lot of searching I found a bash script which makes a list of data files and passes them one by one to a gnuplot script. The idea being that I can create 328 graphs from 328 data files automatically using only one gnuplot script fed by one bash script. The (Andy Carter's) bash script is shown below (here his example of a gnuplot script is called plot.gnu),
#! /bin/bash
ls *.data | sed "s/.data//" > list
for i in `cat list` ; do
sed -e "s/INPUTFILE/$i/" -e "s/OUTPUTFILE/$i/" \
plot.gnu | gnuplot
done
rm list
plot.gnu in this example is,
set term postscript enhanced color
set output 'OUTPUTFILE.eps'
set title 'OUTPUTFILE'
p 'INPUTFILE.data' u 1:2 w l
OUTPUTFILE is used to set the output of the gnuplot script (e.g. an .eps file) and also the title of the graph, and the INPUTFILE is used as input for the plot command.
My gnuplot script is a little more detailed, but includes similar commands.......
OK so far...but I need to also alter the x range and xtics values for each new graph as they are different each time, in one graph the x values (column 1)might be integers 1 to 30, in the next graph integers between 60 and 130. The y1 and y2 axes (columns 2 and 3) can be plotted using a defined range so that's not a problem. The data files are plain text, tab-delimited.
To set the xrange and xtics I need the first value of column 1 and the last value in column 1 of each data file as variables for the gnuplot script.
Any ideas how I can add commands to the bash script that will extract these values from each data file and pass them along with the associated OUTPUTFILE and INPUTFILE to the gnuplot script?
Thanks
Steve


Reply With Quote