[GnuPlot Home Page]
Tutorials and FAQs
Language Bindings
Batch Processing Tips
You want to make lots similar figures with gnuplot but with different data-sources. For each data source you want do customize the title and some other stuff. What can you do?
Well,
[this page] has some tips, lack others but, from what I read, those are the best options you have:
- Use environment variables and backslash-quoted commands inside your plot-file:
- set title "`echo $PLOT_TITLE`"
- Use some text util to replate some key-words in you plot-file and pipe the result to gnuplot:
- sed "s/TITLE_NAME/$PLOT_TITLE/" plotfile.gnu | gnuplot
- [You can write gnuplot commands directly in a shell script]
#!/bin/sh
gnuplot << EOF
set terminal postscript eps color enhanced
set output "$1.eps"
set xlabel "Energy [MeV]"
set ylabel "Cross Section [b]"
set title "(n,2n) reaction"
set xrange [ 0 : 20 ]
set yrange [ 0 : 2 ]
set mxtics 5
set mytics 5
set xtics 5
set ytics 0.5
plot "$1.dat" using 1:2 notitle w l
EOF
Merging two eps into one
Based on code from
http://www.duke.edu/~hpgavin/gnuplot.html.
More tips can be found at
http://t16web.lanl.gov/Kawano/gnuplot/postproc-e.html#8.2
#!/bin/bash
# cat2eps.sh: Shell script for putting two Gnuplot plots on one page
set -e;
function show_usage()
{
echo "Usage: cat2eps.sh [arq1.eps] [arq2] > output.eps" > /dev/stderr;
}
if [ "x$1" == "x" ]; then
show_usage;
exit 1;
fi
if [ "x$2" == "x" ]; then
show_usage;
exit 1;
fi
echo %!;
echo gsave;
echo 0 400 translate; # for Gnuplot plots
cat $1 | sed -e "s/showpage//";
echo grestore;
echo gsave;
echo 0 090 translate; # for Gnuplot plots
cat $2;