plotgen

来自「EM算法的改进」· 代码 · 共 314 行

TXT
314
字号
#!/bin/csh### $Id: plotgen 1339 2006-09-21 19:46:28Z tbailey $## $Log$## Revision 1.2  2005/10/05 06:18:35  nadya## use full path for "rm". Asssume everybody has /bin/rm.#### Revision 1.1.1.1  2005/07/29 00:00:42  nadya## Importing from meme-3.0.14, and adding configure/make###set pgm = $0; set pgm = $pgm:tif ($#argv < 1) then  error:  more << "USAGE"  USAGE:	$pgm [<label> <data>] [-ps|-png <name>] 	  [-xlabel <xlab>] [-ylabel <ylab>] 	  [-xlaboff <xlaboff>] [-ylaboff <ylaboff>]          [-xrange [<x1>] : [<x2>] [-yrange [<y1>] : [<y2>]	  [-key <x> <y>] [-misc <whatever>] [-file <file>]	  [-size <size>] [-point <psize>] [-rm_] [-big] [-f] [-nocat]	<label>			label for curve  	<data>			file of points to plot;				if the file does not exist, then <data>				is assumed to be a function defined in				a -misc or -file command	[-ps|-png <name>]	plot to .ps or .png file <name>.ps 				or <name>.png, tex file <name>.tex				plot to screen if <name> is "_screen_"				default is screen	[-xlabel <xlab>]	label for x axis	[-ylabel <ylab>]	label for y axis	[-xlaboff [<xoff>][,<yoff>]]	offset for label for x axis	[-ylaboff [<xoff>][,<yoff>]	offset for label for y axis	[-xrange [<x1>] : [<x2>]range for x axis	[-yrange [<y1>] : [<y2>]range for y axis	[-key <x> <y>]  	position key at <x,y>	[-title <title>]	title for plot; underscores are blanked	[-misc <whatever>]+	any gnuplot command(s) separated by ';'	[-file <file>]		file containing gnuplot commands;	[-size <xsize> <ysize>]	scale-factor for size of plot	[-point <psize>]	point size for text on plot; default = 11	[-rm_]			replace underscores with blanks in				<label>, <xlab> and <ylab>	[-big]			make 65in, two column figure	[-[no]color]		make a [non-]color figure	[-f]			force: overwrite files if they exist	[-nocat]		don't print the plot script; default: cat the script to STDOUT	Plots one or more curves from files containing <x, y> pairs.	Default is to screen.	The -misc commands followed by the -file are done just before	any plot commands generated by the <label> <data> pairs.	Underscores in <title> are replaced by blanks. 	Creates files:		<name>.[ps|png]		<name>.tex		tmp.tex"USAGE"  exit 1endifset command = ($0 "$*")onintr cleanupset ncurves = 0set label = (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)set data = ""set misc = ""; set point = 11set miscfile = $pgm.miscfile.$$.tmpset xlaboff = ""set ylaboff = ""set color = ""set force = 0# tex figure parametersset col = "" set width = "\widtha"# get input switcheswhile  ("$1" != "")  switch ("$1")  case -ps:  case -png:    if ($2 == "_screen_") break    set name = $2:t;     if ("$1" == "-ps") then      set otype = "ps"      set out = $2.ps; set latex = $2.tex; set latex2 = $latex    else       set otype = "png"      set out = $2.png;    endif    shift    breaksw  case -key:    set key = "set key ${2},${3}"; shift; shift; breaksw  case -xlabel:    set xlab = "$2"; shift; breaksw  case -ylabel:    set ylab = "$2"; shift; breaksw  case -xlaboff:    set xlaboff = $2; shift; breaksw  case -ylaboff:    set ylaboff = $2; shift; breaksw  case -xrange:    shift;     if ($1 != ":") then      set xrange = "[$1 : $3]"; shift; shift;    else       set xrange = "[ : $2]"; shift    endif    breaksw  case -yrange:    shift;     if ($1 != ":") then      set yrange = "[$1 : $3]"; shift; shift;    else       set yrange = "[ : $2]"; shift    endif    breaksw  case -title:    set title = `echo $2 | sed s/_/" "/g`; shift; breaksw  case -misc:    if !(-e $miscfile) touch $miscfile    shift; echo "$1" >> $miscfile; breaksw    #set misc = ("$misc" "$2" ;); shift; breaksw  case -file:    set gnufile = "$2"; shift; breaksw  case -size:    set xsize = $2; shift; set ysize = $2; shift; breaksw  case -point:    shift; set point = $1; breaksw  case -rm_:    set rm_ = 1; breaksw  case -big:    set col = '*'; set width = "6.5in"; breaksw  case -color:    set color = "color"; breaksw  case -nocolor:    set color = ""; breaksw  case -f    set force = 1; breaksw  case -nocat    set nocat = 1; breaksw  default:    @ ncurves++    if ($ncurves > $#label) then      echo Too many curves specified | perl -n -e 'print stderr $_'      exit 1    endif    set label[$ncurves] = "$1"    set data = ($data $2)    shift; breaksw  endsw  shift#  echo $1end# check that at least one curve to be printed#if ($ncurves < 1) goto error# set up the file which will receive the plot set gnuplot = $pgm.plotscript.$$.tmpif ($?out) then  if ((-e $out) && $force == 0) then    echo "File $out already exists.  Overwrite? (n)" | perl -n -e 'print stderr $_'    set ans = $<    if (!($ans == "y" || $ans == "Y")) then      exit    endif    /bin/rm $out  endif  echo Output will be to $otype file $out | perl -n -e 'print stderr $_'  if ("$otype" == "ps") then    echo "set terminal postscript eps $color $point" > $gnuplot  else    if ($point < 20) then      set psize = "small"    else if ($point < 30) then      set psize = "medium"    else       set psize = "large"    endif    echo "set terminal png $psize" > $gnuplot  endif  echo "set output '/dev/null'" >> $gnuplotelse  echo Output will be to screen | perl -n -e 'print stderr $_'  echo -n "" > $gnuplotendif# set up the file which will receive the latex figures (.tex file)if ($?latex) then  if ((-e $latex) && $force == 0) then    echo "File $latex already exists.  Overwrite? (n)" | perl -n -e 'print stderr $_'    set ans = $<    if ($ans == "y" || $ans == "Y") then      /bin/rm $latex    else      set latex = /dev/null    endif  endif  echo -n "" >! $latex# print the header for a latex document  echo "\documentclass[12pt]{article}" >! tmp.tex  echo "\usepackage{times,a4,graphicx}" >> tmp.texendifif ($?title) then  if ($?rm_) set title = `echo $title | sed s/_/" "/g`  echo "set title '$title'" >> $gnuplotendifecho "set data style linespoints" >> $gnuplotif ($?xlab) then  if ($?rm_) set xlab = `echo $xlab | sed s/_/" "/g`  echo "set xlabel '$xlab' $xlaboff" >> $gnuplotendifif ($?ylab) then  if ($?rm_) set ylab = `echo $ylab | sed s/_/" "/g`  echo "set ylabel '$ylab' $ylaboff" >> $gnuplotendifif ($?xrange) then   echo set xrange "$xrange" >> $gnuplotendifif ($?yrange) then  echo set yrange "$yrange" >> $gnuplotendifif ($?key) then  echo "$key" >> $gnuplotendifif ($?xsize) then  echo set size $xsize,$ysize >> $gnuplotendif#foreach com ($misc)#  if ($com != ";") then#    echo -n "$com " >> $gnuplot#  else#    echo "" >> $gnuplot#  endif#endif (-e $miscfile) cat $miscfile >> $gnuplotif ($?gnufile) then  cat $gnufile >> $gnuplotendifset plotcmd = plotset i=1while ($i <= $ncurves)# plot the points  if ($?rm_) then     set curve_title = `echo $label[$i] | sed s/_/" "/g`  else    set curve_title = $label[$i]  endif  echo "curve ${i}: $curve_title" | perl -n -e 'print stderr $_'  if (-e "$data[$i]") then    echo "$plotcmd '$data[$i]' title '$curve_title'" >> $gnuplot  else    echo "$plotcmd $data[$i] title '$curve_title'" >> $gnuplot  endif  set plotcmd = replot  @ i++end#echo "replot" >> $gnuplot#echo "replot" >> $gnuplotif (!($?out)) then  echo "pause 1e6 'Hit ^C to exit: '" >> $gnuplotelse  echo "set output '$out'" >> $gnuplot  echo replot >> $gnuplot  # make a latex file if required  if ($?latex) then    echo "\begin{figure$col}" >> $latex    echo "\centerline{" >> $latex    echo "  \includegraphics[width=$width]{$out}" >> $latex    echo "}" >> $latex    echo "\caption{$name}" >> $latex    echo "\label{fig:$name}"  >> $latex    echo "% $command" >> $latex    echo "\end{figure$col}" >> $latex    echo "\markfigure{\ref{fig:$name}}" >> $latex  endifendif# end the latex documentif ($?latex) then  echo  "\begin{document}" >> tmp.tex  echo  "\input{$latex2}" >> tmp.tex  echo  "\end{document}" >> tmp.texendif# execute the gnuplot scriptif (!($?nocat)) then  cat $gnuplot | perl -n -e 'print stderr $_'endifgnuplot $gnuplotcleanup:/bin/rm $pgm.*.$$.tmp

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?