General Utilities

Graphics and Plotting

This section is divided into two parts: the first describes, in general terms, graphics tasks available to STSDAS/TABLES users; the second part (beginning on page
74) is a tutorial showing how some of these tasks can be used. If your site has only TABLES, but not STSDAS, installed then you will only be able to use the igi and sgraph tasks, and their related parameter sets axispar, dvpar, and pltpar, in addition to the traditional graphics tasks distributed with the IRAF system.

Graphics Tasks Overview

STSDAS users can often use the general facilities in the IRAF plot package. However, the plot package cannot plot data from STSDAS tables, and will not plot data from multi-group STSDAS format data files very effectively. Thus, STSDAS provides its own plotting package, stplot, as an adjunct to the functions provided in IRAF.

The sgraph task contains all of the functions of IRAF's general purpose plotting (i.e., the graph task in the plot package), but has added capabilities. In addition to plotting from IRAF or STSDAS images and text files (STDIN), sgraph will plot values from STSDAS tables. One may plot a single column against row number or one column against another column in the same table or another table. Lists (text files) and image sections can be mixed in the input parameter. If the curves are of different lengths, the plot will be scaled to the longest curve and curves will be left justified. If an image section has more than one dimension, the average projection will be computed and plotted along a designated axis. A unique dash pattern (up to 4) is used for each curve (by default).

The depind task prints pairs of dependent and independent pixel values from two one-dimensional images to STDOUT. This may be piped to sgraph or graph to plot one image line (spectrum) against another. A useful application of this task is plotting fluxes in one file against wavelengths in another file.

The skymap task interprets an STSDAS table as a catalog of coordinates and brightness to produce a star chart. That is, it plots symbols whose size depends on brightness (i.e., magnitude) and whose position on the plot is a projection of the celestial coordinates. There is an interactive interface which allows a user to roam the catalog, change the chart scale, and perform other actions.

Two tasks deal with group format STSDAS images and can be used to plot more than one group member on a single graph. The grplot task overplots selected group members on a single plot. The grspec task uses the specplot task in the NOAO onedspec package to allow interaction with a plot of several group members.

The fieldplot task is a general purpose plotting task to draw arrows representing directions and magnitudes (vector fields). Data are read from a text file, or from STDIN, to represent the coordinates of a point and the field vector. The vector may be either a pair of projected magnitudes or the absolute magnitude and direction. The magnitude may be scaled arbitrarily.

histogram plots data in a histogram format. The data can be read from an STSDAS table, STSDAS or IRAF image, or text file.

The igi task is an interactive interpreter for producing arbitrary plots. Although igi is a complete graphics program in itself, it operates within IRAF and is layered on the same low-level graphics facilities.

newcont is an alternative to the contour task in IRAF's plot package. It implements a different algorithm for computing contours that can produce more accurate results, but at some cost in efficiency. It also includes additional capabilities, such as choosing arbitrary contour levels and contours with different line types.

siaper draws HST science instrument apertures and may be used to display the HST field of view. You can overlay the plot on a displayed image to help position targets.

wcslab draws axes, ticks, and labels in the coordinate system defined in the parameters of a two-dimensional image. You can overlay these axes on a displayed image. (Note that this is a different task from the wcslab task found in the IRAF plot package).

The igi and sgraph tasks (and their associated parameter sets) are included in the TABLES package in the tbplot package.

Tutorial: Plotting and Other Graphics

This section explains how to generate plots in the IRAF and STSDAS environment. This section will explain:

Basic Plotting Tools

FOS and GHRS observers can plot spectral data using the
splot and fwplot tasks. WF/PC and FOC observers can plot image data using the implot and contour tasks.

There are a few basic plotting tasks that you should investigate (roughly in increasing order of generality):

Plotting tasks may be interactive or non-interactive. The fwplot task is an example of a non-interactive graphing task which draws a plot and returns to the CL. It produces a plot with no further control other than by rerunning the task. Interactive plotting tasks such as splot permit immediate interactive control over the operation of the task by entering cursor mode commands typed from the keyboard.

Plots produced by non-interactive tasks on a graphics display may still be modified to some extent using cursor mode, although there is no control over the task itself. Type =gcur to enter cursor mode from the CL. In cursor mode, a number of commands become available. The most important of these are:

From the CL prompt, type help cursor for an explanation of how the graphics facility works and how to use common cursor commands.

Printing Plots

There are two ways to print a plot:

Device Parameter

To send the plot to the printer initially, set the task's device parameter, for example:

cl> set implot.device=stdplot
You can define the CL variable stdplot in your or file; you can set it to be any printer known to IRAF. When you run the plotting task, there will be no visible plot on the screen, instead, it will be printed on the specified printer. Use the gflush command to send the plot to the printer.

Remember to use gflush after sending a plot to a printer.


You can print any plot drawn on the screen using the cursor mode command :.snap or it's shortcut, the key. You must be in cursor mode for this to happen. Interactive plotting tasks put you in cursor mode. You can always enter cursor mode by typing =gcur at the CL prompt.

Plots will be printed on the printer defined by the environment variable stdplot. (See
"Setting Environment Variables" on page 18).

Using fwplot

GHRS and FOS observers can quickly produce a flux vs. wavelength plot of a spectrum using the fwplot task in the STSDAS ctools package. This takes a single argument--the name of the calibrated flux (.c1h) file.

Simple Flux Versus Wavelength Plot of Spectral Data

Using splot

The splot task is used to plot one-dimensional data. Although you can use the task directly on your calibrated HST spectra, most observers find splot most useful after combining the wavelength and flux information using the mkmultispec task. When running mkmultispec, exclude unexposed pixels using the range syntax described in "Image Sections and Groups" on page 28.

Figure 4.6 shows an example of how a typical FOS observer might combine the wavelength and flux using mkmultispec and then plot the data using splot.

Reminder: Use the help command (or phelp) to find out more about these tasks.

Using splot with Combined FOS Flux and Wavelength

Using implot

The IRAF implot task (in the plot package) will let you interactively examine an image by plotting data along a given line (X axis) or column (Y axis). When you run the task, a large number of commands are available, in addition to the usual cursor mode commands common to most plotting tasks, a complete listing of commands is found in the on-line help, but the most common are listed in Table 4.2.

Basic implot Commands

Plotting Image Data with implot

Contour Plots

Contour plots of image data can be created using the newcont task in the STSDAS stplot package. This is similar to the contour task in the IRAF plot package, but uses a different contouring algorithm and includes additional capability such as labeling in world coordinates. Figure 4.8 is an example of how to use the task with a WF/PC image.

Contour Plots Using newcont

Using igi

As your plotting needs grow more sophisticated--and especially as you try preparing presentations or publication-quality plots--you should investigate the Interactive Graphics Interpreter, or igi. This is a task in the STSDAS stplot package that can be used to draw axes, error bars, labels, and a variety of other features on plots. Options are available to use a number of different line weights, font styles, and feature shapes, enabling you to create complex plots. Figure 4.9 shows a very simple example plot created in igi and the commands that were used to do it.

Sample igi Plot

In addition to standard graphing facilities, igi includes some data manipulation capabilities and programming capabilities, such as macros. There are also commands for rendering grayscale and pseudo-color images.

Because igi is a complete graphics environment in itself, a full description is well beyond the scope of this document. You can learn more about igi by reading the on-line help (help igi from within IRAF) or by reading the IGI Reference Manual, available from the STSDAS Hotseat.

PostScript Plots

STSDAS tasks can take advantage of many PostScript capabilities using the PostScript kernel, or psikern. Once installed, psikern provides PostScript capabilities such as the ability to work with color, and to do grayscale image rendering. These features are provided transparently--you simply specify the name of the printer (as known to IRAF) that you wish to use. This allows you to print plots directly to PostScript printers or to save them in Encapsulated PostScript (EPS) files which can then be imported into documents or rendered on the screen with a PostScript viewer such as PageView or GhostScript.

Not all tasks make use of these extended capabilities, but some of the graphics.stplot tasks do let you specify colors and render gray scale images. In particular, igi takes advantage of all of the added capability of psikern, including selection of color, filled-area patterns, and continuous-tone monochrome and color images. Other tasks such as newcont, skymap and wcslab take advantage of color. Any graphics task in STSDAS and IRAF can make use of improved font support.

There are two commonly-used ways to create a PostScript file of your plot (see the on-line help; type help psikern):

  1. With the plot displayed, from cursor mode, type:
    :.snap psi_port (or psi_land)

  2. Before running your plot task, set the device parameter to psi_port or psi_land.

The system will automatically name the file, and usually store it in a temporary directory. When you type gflush, you will see the file name as created by psikern. You should then move the file to an appropriate directory where it won't be deleted. For example:

st> sgraph dev$pix device=psi_land
st> gflush
st> copy /tmp/psk4575a home$
Graphics Tasks Overview
Tutorial: Plotting and Other Graphics
Basic Plotting Tools
Printing Plots
Device Parameter
Using fwplot
Using splot
Using implot
Contour Plots
Using igi
PostScript Plots

Generated with WebMaker