3 Starlink-PGPLOT

 3.1 Using the GKS version
 3.2 Starlink-PGPLOT device names
 3.3 Starlink-PGPLOT examples
 3.4 Plotting in the current viewport

Readers interested in the Native-PGPLOT version should refer to section Native-PGPLOT.

3.1 Using the GKS version

There are two ways in which the GKS version of PGPLOT can be used:

(1)
As a self contained graphics package where all graphics, including opening and closing the workstation, is done with PGPLOT. Programs written in this way can be run with other implementations of PGPLOT. Such programs are linked with the command:

% f77 prog.f -L/star/lib ‘pgp_link‘

(2)
To plot a picture in the current viewport of an already open GKS workstation (see Plotting in the current viewport).

To use PGPLOT in an ADAM application, consult the ADAM Graphics Programmer’s Guide (SUN/113).

3.2 Starlink-PGPLOT device names

Any graphics device supported by GKS can be used with Starlink PGPLOT and device names are translated using the graphics name service described in GNS – Graphics Name Service (SUN/57). Device names containing a ‘/’ character (such as UNIX file names) must be surrounded by quote (‘"’) characters.

If a question mark is typed in response to the prompt from PGBEG, a list of those workstation names defined on your system will be listed on the terminal.

On some hard copy devices the output from a PGPLOT program is a file and some further action (such as printing the file) is required to produce a plot. If you are unfamiliar with a particular device, consult SUN/83.

If one of the metafile workstations is selected the metafile can be tailored for a particular real workstation type by appending /TARGET=workstation to the device specification. The default target is the monochrome A4 Postscript workstation. The resulting metafile can be played back on any workstation but will be tailored with respect to such things as resolution, number of colour indices, etc. for the selected target.

The device name syntax described in the PGPLOT manual is also supported; when using this form of device name, the device type is specified using a GNS workstation name.

3.3 Starlink-PGPLOT examples

On non-Starlink systems you may have to replace /star by some other path name to locate the files referred to in this section.

The directory /star/share/pgp contains the source of a number of example programs which demonstrate most of the features of PGPLOT. Binaries of the example programs can be found in /star/bin/examples/pgp.

They can be run with a command such as:

/star/bin/examples/pgp/pgdemon

where n is between 1 and 14, provided that they have been installed. (They may not have been in order to save disk space).

3.4 Plotting in the current viewport

PGPLOT can be used to plot a picture in the current viewport on an already open GKS workstation. When used in this way, the second argument to PGBEG (normally the workstation name) is a GKS workstation identifier (encoded as a character string). PGPLOT then behaves as if the region of the display surface defined by the current viewport is a complete workstation. When PGEND is called the workstation is not closed but the state of GKS is restored to what it was at the time that PGBEG was called.

PGPLOT assumes that it has exclusive control over the GKS and so the only graphics calls allowed between PGBEG and PGEND are PGPLOT routines and GKS inquiry routines.

The following simple example is a subroutine that uses PGPLOT to draw an X, Y plot in an SGS zone.

       SUBROUTINE XYPLOT (IZONE, X, Y, N, XLO, XHI, YLO, YHI, ISTAT)
  *++
  *
  *   XYPLOT   Draw X,Y plot in an SGS zone.
  *
  *   Description:
  *
  *      Uses PGPLOT to draw an X,Y plot of the real arrays X & Y in the
  *      region of the display surface defined be the specified SGS zone.
  *
  *   Input arguments:
  *
  *      IZONE    INTEGER         SGS zone identifier
  *      X        REAL(N)         X values of data points
  *      Y        REAL(N)         Y   "    "    "    "
  *      N        INTEGER         Number of data points
  *      XLO      REAL            Lower X axis limit
  *      XHI      REAL            Higher X  "    "
  *      YLO      REAL            Lower Y  "     "
  *      YHI      REAL            Higher Y  "    "
  *
  *   Output arguments:
  *
  *      ISTAT    INTEGER         SGS status
  *
  *   Side effects:
  *
  *      The specified SGS zone is selected.
  *++
       IMPLICIT NONE
       INTEGER  IZONE, N, ISTAT, PGSTAT
       REAL     X(N), Y(N), XLO, XHI, YLO, YHI
  
       CHARACTER*10 WKID
       INTEGER IWKID
  
       INTEGER PGBEG
  
  
  *  Select the specified SGS zone.
       CALL SGS_SELZ(IZONE, ISTAT)
       IF (ISTAT.EQ.0) THEN
  
  *     Inquire the GKS workstation identifier of the current zone.
          CALL SGS_ICURW(IWKID)
  
  *     Encode workstation id as a character string.
          WRITE(UNIT=WKID, FMT=’(I10)’) IWKID
  
  *     Open PGPLOT
          PGSTAT = PGBEG(0, WKID, 1, 1)
          IF (PGSTAT.EQ.1) THEN
  
  *     Define axis limits.
             CALL PGENV(XLO, XHI, YLO, YHI, 0, 0)
  
  *     Plot the data.
             CALL PGPT(N, X, Y, 2)
  
  *     Close down PGPLOT.
             CALL PGEND
          END IF
       END IF
       END

Because other plotting packages may have plotted on the same physical device, there are some restrictions when using PGPLOT in this way: