#!/bin/tcsh -f # mar99 ..... usage: gplot dat [ 1 3 ] which does: ### gnuplot dat [u 1:3 ] > dat.ps ; gv dat.ps ### how it works: ### ~/S/gnuplot.sh produces $dat.gp from ~/S/gnuplot_template ### by replacing OUTPUT, COL1, COL2, DATA ### by $dat.ps $col1, $col2, $dat ### then 'gnuplot < $dat.gp' produces $dat.ps ### then 'gv $dat.ps' displays it !!! neat !!! ### apr99: then also replace TITLE,XLABEL,YLABEL by entered strings ### and even save the labeled .ps ! works great ! ### idea from Phil Mucci, this script plays the role of Makefile ###......... use local template or the global one: set template = "./gnplot_template" if( ! -f "$template" ) set template = "~/S/gnuplot_template" echo " ... using $template as template ..." set gnuplotsh = "./gnuplot.sh" if( ! -f "$gnuplotsh" ) set gnuplotsh = "~/S/gnuplot.sh" set fl = "$1" set col1 = "1" set col2 = "2" set ext = "none" if( "$1" == "" ) then echo -n " Enter file (or file.gz): " set fl = $< endif #----------------------- gunzip if .gz ---------------------- set dat = `basename "$fl" .gz` echo " dat= $dat" if( -f "${dat}.gz" ) then echo " ... found $dat.gz ... will gunzip it ..." gunzip ${dat}.gz set ext = gz endif set yesno = "y" #------------------------ begin while loop ---------------------- while( "$yesno" == "y" ) if( "$2" == "" || "$3" == "" ) then #....choose columns: echo -n " Enter column1 to plot [${col1}]: " set col1 = $< echo -n " Enter column2 to plot [${col2}]: " set col2 = $< endif if( "$col1" == "" ) set col1 = "1" if( "$col2" == "" ) set col2 = "2" echo " using $col1 $col2" #.............. produce $dat.gp ......... $gnuplotsh $template $dat.gp "OUTPUT" $dat.ps "COL1" $col1 "COL2" $col2 "DATA" $dat #....................... produce (unlabeled) plot and view it: # gnuplot < $dat.gp # echo -n " gv the .ps ? n for NOT : " # set yes = $< # if( "$yes" != "n" ) gv $dat.ps & #........... or call gpgp ....... which does all this: ~/S/gpgp $dat.gp ###---------------- view more plots ? echo "" echo -n " ---> ? another plot ? ---> enter y : " set yesno = $< end #while #------------------------ end of while loop --------------------------- echo "" #------------------------ cleanup /bin/rm -i $dat.gp $dat.ps /bin/rm -f $dat.was if( $ext == "gz" ) then echo "" echo -n " ---> file was .gz , will gzip it unless n : " set yes = $< if( $yes != "n" ) gzip $dat endif exit