Gnuplot Graphics
New releases (3/2000 and later) of unix TSP include a beta test version
of gnuplot graphics, with the PLOT and GRAPH commands.
(So far, this is available on Sun, linux, IBM RS/6000 and HP-UX).
PLOT and GRAPH will still produce the old character
plots in the output file by default. To enable the
gnuplot graphics, use:
- OPTIONS DISPLAY=X11GNU;
produces video plots for
every subsequent PLOT/GRAPH command, in
persistent windows, under Xwindows.
To change the default back to character plots, use
OPTIONS DISPLAY=NONE; .
NOTE: the video plots are untested at this
time, although I believe the gnuplot commands are correct.
It causes use of the -persist flag in the gnuplot command
line, and 'set term=x11' in the gnuplot commands.
- PLOT(PREVIEW,...) or GRAPH(PREVIEW,...)
produces a video plot for just this command.
- PLOT(DEV=GIF,...) or GRAPH(DEV=GIF,...)
stores a .gif file with the plot image.
This plotting mode was used to test all the graphics.
(on linux, the .gif file is clipped a little too aggressively).
Both PREVIEW and DEV=GIF can be used in the same command.
Example
smpl 1,10;
trend t;
plot(dev=gif) t;
This stores the file plot1.gif with the plot image. While PLOT
is executing, the following temporary files are created and
eventually deleted: plot1.gpl, plot1.ppm, and T._ .
GIF examples:
- SAMPSEL - 3 local optima
GRAPH(LINE,TITLE='...',FILE='sampsel',DEV=GIF) RHO LOGL;
Produced on the Sun, without any clipping problems.
- Grunfeld panel data - fitted values
FREQ(PANEL,T=20);
PLOT(TITLE='...',FILE='grun',DEV=GIF) I IPOOL IFIXED;
Note: for these stacked panel data, there is a break in the
line between each individual. This feature was implemented in
TSP on 3/9/01.
Required Programs
- gnuplot
- (tested with gnuplot version 3.5 on Sun (8/93) and Linux (6/98) )
- The 6/98 "pre 3.6" version allows for a better graph legend
(instead of the datafile name). However, this feature is not used
by TSP yet.
- Download location: unknown, but it seems to be commonly installed.
(gnuplot was installed on the RS/6000 and HP-UX systems where I
updated the TSP ports).
- ppmtogif
- Required for DEV=GIF, so the large .ppm file can be translated to
the compact .gif file. Try "help set term pbm" within
gnuplot for more information.
- A special "silent" version of ppmtogif is included in the linux .zip
file with tsp. It omits 2 messages which occur every time the
standard version of ppmtogif is run:
"ppmtogif: computing colormap..." and
"ppmtogif: 3 colors found".
- We have located binary versions of ppmtogif for Sun, linux, and
IBM RS/6000. We haven't looked for one for HP-UX yet.
- Download location for portable ppmtogif source:
ftp://ftp.x.org/contrib/utilities/netpbm-1mar1994.p1.tar.gz
New options for PLOT and GRAPH
- DEV=CHAR/[NONE]/GIF
DEV=GIF stores a .gif file with the plot image. Once you use
DEV=GIF in a PLOT or GRAPH command, it becomes the default for
all subsequent PLOT and GRAPH commands. It could be turned off
by using DEV=NONE in a later command. If the default FILE=AUTO
is used, the .gif files will be named plot1.gif, plot2.gif, ....
For DEV=GIF, gnuplot actually creates a (large) temporary .ppm file
first, and tsp uses ppmtogif to translate it to a .gif file.
- FILE=[AUTO]/"filename"
This controls the prefix filenames used for temporary files,
and for .gif files. The default FILE=AUTO makes the prefixes
plot1, plot2, .... GRAPH(FILE='x_y',DEV=GIF) X Y; would store
x_y.gif .
- SAVE/[NOSAVE]
Use SAVE if you want to modify the gnuplot commands produced by
TSP. For example, you could change the line style to
linespoints, or make a nicer legend. In the example given
above, plot1.gpl and T._ would be saved. plot1.gpl contains
the gnuplot commands, and T._ contains the time axis values
and T data values.
Edit plot1.gpl and use something like the commands:
gnuplot -persist plot1.gpl
ppmtogif plot1.ppm > plot1.gif
rm plot1.ppm
Old options/features supported for PLOT and GRAPH
- TITLE='string'
- GRAPH(LINE)
- GRAPH(PAIR)
- PLOT handles missing values by making a break in the plot line.
NOTE: the gnuplot version of PLOT will not run if there are
SMPL gaps; you will get a character plot instead.
Thanks to Lars Kristensson of Stockholm University for
suggesting the use of gnuplot, and providing a useful
shell script to demonstrate it. Other packages, such as Shazam,
have used gnuplot for quite awhile.
rev. April 26, 2000
Tech support email:
clint@leland.stanford.edu