ECG Database Applications Guide Table of Contents


plot2d, plot3d - make 2-D or 3-D plots from text files of data, using gnuplot


plot2d [ input-file ] [ [ xcol ] ycol ] [ options ... ]
plot3d [ input-file ] [ [ xcol ycol ] zcol ] [ options ... ]


These UNIX shell scripts can be used to produce simple 2-D and 3-D plots using gnuplot(1) in batch (non-interactive) mode. plot2d was designed as a portable, quick-and-dirty replacement for Paul Albrecht's elegant but unsupported plt; plot2d accepts a few of the most commonly-used plt options and produces similar plots. plot3d uses the same syntax as plot2d, but it produces simple 3-D plots (a capability not offered by plt).

The input-file should contain one or more space- or tab-separated columns of data per line, with each point on a line. Omit the input-file argument to read data from the standard input. (Note: since gnuplot cannot read data from a pipe, plot2d and plot3d save piped input in a temporary file before invoking gnuplot.)

xcol, ycol, and zcol specify the column numbers within the input file for the x, y, and z coordinates of the points to be plotted. The leftmost column is column 0 (this convention follows that used by plt, rather than that used by gnuplot). Omit the xcol argument to plot2d to use row numbers as abscissas; if ycol is also omitted, plot2d plots column 1 vs. column 0. When using plot3d, omit both xcol and ycol to generate x and y coordinates sequentially based on row numbers; a blank line in the input resets x and increments y in this case.

Options include:

Print help and exit (no plot is made).
-t title
Use title as the title for the plot.
-x label
Use label as the X-axis label.
-y label
Use label as the Y-axis label.
-z label
Use label as the Z-axis label (plot3d only).
-X xmin xmax
Plot x-coordinates between xmin and xmax only.
-Y ymin ymax
Plot y-coordinates between ymin and ymax only.
-Z zmin zmax
Plot z-coordinates between zmin and zmax only (plot3d only).
-T printer
Produce output on the specified PostScript printer (default: plot on-screen). Use -T eps to generate encapsulated PostScript on the standard output.


Create a text file with the following contents:
0 0 0
1 1 1
2 4 8
3 9 27
4 16 64
and call the file powers. Plot the first column vs. the second by:
plot2d powers 0 1 -t "Squares of small integers" -x "Integer" -y "Square"
The same file can be used to generate a number of different plots, by choosing different columns. To plot the third column vs. the first, try: plot2d powers 2 0 -t "Marshmallows" -x "Mass (kg)" -y "Height (m)"


gnuplot is freely available in C source form by anonymous FTP from and many other sites.


This program is included in version 9.3 and later versions of the DB Software Package.

Table of Contents