[sci.electronics] spice3 plot beautifier
Jan Mark Noworolski
jmn at ibiza.berkeley.edu
Sat Oct 13 14:31:17 AEST 1990
Archive-name: sp2xgraph/12-Oct-90
Original-posting-by: jmn at ibiza.berkeley.edu (Jan Mark Noworolski)
Original-subject: spice3 plot beautifier
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)
[Reposted from sci.electronics.
Comments on this service to emv at math.lsa.umich.edu (Edward Vielmetti).]
If any of you use spice3, you no doubt have had noticed the low, low quality
of hardcopy plots (I am talking about the ones resulting from running under
Xwindows, not the chararacter plots).
Well I did, and so I sat down and wrote a filter to make spice3 'print'
statement outputs suitable for input to xgraph. Which in turn makes really
nice graphs which you can also include in latex documents if you want.
Some of you might want to use it, so here it is:
(how to get xgraph is described in the shar file also)
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# readme
# sp2xgraph
# sp2xgraph.shar
# This archive created: Thu Oct 11 22:03:46 1990
export PATH; PATH=/bin:$PATH
if test -f 'readme'
then
echo shar: will not over-write existing file "'readme'"
else
cat << \SHAR_EOF > 'readme'
This shell script is a filter to help make presentation quality graphs from
spice3 output, it filters output from spice3 'print' statements to a form
suitable for input to xgraph.
xgraph is a program to plot data sets on an Xwindows display, it is available
by anonymous ftp from shambhala.berkeley.edu (128.32.132.54). These graphs can
then be output in several formats including HPGL, and encapsulated postscript.
Resulting output is much better than what you can get from hardcopies
of plots in spice3, and to boot it can be included as encapsulated postscript
in latex documents (don't ask me how to do this, I haven't tried yet).
Bug reports and (preferably) improvements to jmn at united.berkeley.edu
SHAR_EOF
fi # end of overwriting check
if test -f 'sp2xgraph'
then
echo shar: will not over-write existing file "'sp2xgraph'"
else
cat << \SHAR_EOF > 'sp2xgraph'
#!/bin/csh
set ylabel="Voltage"
set xlabel="Time"
while ($#argv > 0)
switch ("$argv[1]")
case -i:
if ($#argv <1) goto usageerror
set ylabel="Current"
shift
breaksw
case -f:
if ($#argv < 1) goto usageerror
set xlabel="Frequency"
shift
breaksw
case -xl:
if ($#argv < 2) goto usageerror
set xlabel="$argv[2]"
shift
shift
breaksw
case -yl:
if ($#argv < 2) goto usageerror
set ylabel="$argv[2]"
shift
shift
breaksw
case -pn:
if ($#argv < 2) goto usageerror
set plotname="$argv[2]"
shift
shift
breaksw
case -s:
set fn
if !($?plotname) set plotname=$fn endif
shift
breaksw
default:
set fn=$argv[1]
if !($?plotname) set plotname=$fn endif
shift
breaksw
endsw
end
if ($?fn) then
sed -e '/\$/,/^----/d' -e 's/^Index *[^ ]* */\"/' -e 's/^ *.*$//' -e '/^--*/d' -e 's/^0 */move /' -e 's/^[0-9]*//' -e '1i\\
TitleText: '"$plotname"'\\
XUnitText: '"$xlabel"'\\
YUnitText: '"$ylabel"' ' -e 's/\,[ ]*[+-0-9e]*//g' $fn
else
usage:
echo -n
echo 'Usage:'" $0 [options] filename"
echo "This program translates spice3 print command output to xgraph input format."
echo "It WILL handle multiple variables in one file- provided they were put there"
echo "by _consecutive_ print statements. ie. 'print i1 i2 > filename' will not work"
echo "but 'print i1 > filename' followed by 'print i2 >> filename' WILL work."
echo "Output is on stdout. Author: jmn at power.berkeley.edu"
echo "Options are:"
echo " -i Set YAxisLabel to 'Current' (default is 'Voltage')"
echo " -f Set XaxisLabel to 'Frequency' (default is 'Time')"
echo " -xl XName Set XaxisLabel to Xname"
echo " -yl YName Set YaxisLabel to Yname"
echo " -pn PlotName Set PlotTitle to PlotName (default is filename)"
echo " -s Take input from stdin"
echo -n
echo "Example Usage:"
echo "$0 -xl 'log(frequency)' -yl 'Gain(db)' -pn '741 Plot' filename | xgraph"
echo "will plot a graph called '741 Plot' with Gain(db) vs log(frequency)."
exit 1
usageerror:
echo $argv[1] needs more arguments!
goto usage
endif
SHAR_EOF
chmod +x 'sp2xgraph'
fi # end of overwriting check
if test -f 'sp2xgraph.shar'
then
echo shar: will not over-write existing file "'sp2xgraph.shar'"
else
cat << \SHAR_EOF > 'sp2xgraph.shar'
SHAR_EOF
fi # end of overwriting check
# End of shell archive
exit 0
--
"There's a really fine line between clever and stupid"
Nigel- Lead Guitar (Spinal Tap)
jmn at united.berkeley.edu, or jmn at power.berkeley.edu
More information about the Alt.sources
mailing list