A bash script to plot multiple files in old version of gnuplot
For gnuplot version older than 4.4, ‘plot for’ is not an option to plot multiple files. In order to make it work and easier, I wrote a BASH script to generate the gnuplot input for multiple file plotting. You are lucky too find this if you are still using old version of gnuplot. No need to use it for the lastest version.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/bin/bash echo "#############################################" echo -e "A bash script to generate gnuplot input.\n\ Author: Ting Li\n\ Email: Dr.Ting.Li@gmail.com\n\ Date: 05/05/2010" echo "#############################################" if [ "$1" == "" ];then echo "Please give file name(s) to make plots. Filename globbing is allowed." echo "You may need to use 'set -f' to disable globbing first if you enter something like '*.txt'." echo "or just add double quote \"*.txt\" to prevent globbing." fi #echo $1 echo "#############################################" echo #the gnuplot script gnuplot_file="myplot.plt" echo "plot \\" > ${gnuplot_file} for f in $1; do # echo $f #the actual plotting options for the plot command in gunplot #the options may be given from a command line argument of this script.(not implemented) echo "'$f' u 1:3 every 1000::1 w l,\\" >> ${gnuplot_file} done # A arbitraty string to end the plot command echo "s=1" >> ${gnuplot_file} #display the contents of the generated gnuplot input file #first, determine the file size fsize=`stat -c%s ${gnuplot_file}` if [ $fsize -gt 11 ];then echo "The contents of the output file ${gnuplot_file} :" echo ">>>>start<<<<" cat ${gnuplot_file} echo ">>>>end<<<<" fi # call gnuplot to make the plot gnuplot -persist ${gnuplot_file} |