      SUBROUTINE PLOT(NPLOTS, NPTS, PTS, LABELS, XCHARS, OUNIT)
C
C<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
C
C   PURPOSE
C   -------
C
C      PRODUCES A SCATTER PLOT OF SEVERAL Y VARIABLES VS. ONE X VARIABLE
C
C   DESCRIPTION
C   -----------
C
C   1.  THE X-VALUES ARE STORED IN THE FIRST COLUMN OF THE ARRAY PTS,
C       AND THE Y-VALUES ARE STORED IN THE SECOND COLUMN OF THE ARRAY
C       PTS.  THE LABELS FOR THE X-AXIS ARE STORED IN THE FIRST COLUMN
C       OF THE LABELS MATRIX, AND THE LABELS FOR THE Y-AXIS ARE STORED
C       IN THE SECOND COLUMN.
C
C   2.  ALL PAIRS OF VARIABLES WILL BE PLOTTED ON ONE PAIR OF AXES, SO
C       THE VALUES OF THE VARIABLES SHOULD BE SCALED SIMILARLY (CLUSTER
C       ROUTINE STAND CAN BE USED TO STANDARDIZE THE VARIABLES.) THE
C       OUTPUT IS ON FORTRAN UNIT OUNIT.
C
C   INPUT PARAMETERS
C   ----------------
C
C   NPLOTS INTEGER SCALAR (UNCHANGED ON OUTPUT).
C         THE NUMBER OF PAIRS OF VARIABLES PLOTTED.
C
C   NPTS  INTEGER VECTOR DIMENSIONED AT LEAST NPLOTS (UNCHANGED ON
C            OUTPUT).
C         NPTS(I) IS THE NUMBER OF POINTS TO BE PLOTTED IN THE I-TH PAIR
C           OF VARIABLES.
C
C   PTS   REAL MATRIX WHOSE FIRST DIMENSION MUST BE 2 AND SECOND
C            DIMENSION MUST BE AT LEAST SUM(NPTS(I)) FOR I=1,NPLOTS
C            (UNCHANGED ON OUTPUT).
C
C         PTS(1,I) STORES THE X-COORDINATE OF THE I-TH POINT.
C         PTS(2,I) STORES THE Y-COORDINATE OF THE I-TH POINT.
C
C   LABELS MATRIX OF 4-CHARACTER VARIABLES WHOSE FIRST DIMENSION MUST BE
C            2 AND SECOND DIMENSION MUST BE AT LEAST NPLOTS (UNCHANGED
C            ON OUTPUT).
C
C         LABELS(1,I) IS THE LABEL OF THE X-AXIS FOR THE I-TH PAIR OF
C            VARIABLES.
C         LABELS(2,I) IS THE LABEL OF THE Y-AXIS FOR THE I-TH PAIR OF
C            VARIABLES.
C
C   XCHARS VECTOR OF 1-CHARACTER VARIABLES DIMENSIONED AT LEAST NPLOTS
C           (UNCHANGED ON OUTPUT).
C         XCHARS(I) IS THE CHARACTER TO BE PLOTTED FOR THE I-TH PAIR OF
C           VARIABLES.
C
C   OUNIT INTEGER SCALAR (UNCHANGED ON OUTPUT).
C         UNIT NUMBER FOR OUTPUT.
C
C   REFERENCE
C   ---------
C
C     HARTIGAN, J. A. (1975).  CLUSTERING ALGORITHMS, JOHN WILEY &
C        SONS, INC., NEW YORK.  PAGES 39, 45.
C
C<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
C
      DIMENSION PTS(2,*), NPTS(*)
      INTEGER OUNIT
      CHARACTER*4 LABELS(2,*)
      CHARACTER*1 B,A(51,26), XCHARS(*)
      DATA B /' '/
C
C     INITIALIZE PLOT MATRIX A.
C
      IU=51
      JU=26
      DO 10 I=1,IU
         DO 10 J=1,JU
   10       A(I,J)=B
C
C     SET RANGES
C
      X1=PTS(1,1)
      X2=PTS(1,2)
      Y1=PTS(2,1)
      Y2=PTS(2,2)
      ISTART=0
      DO 30 I=1,NPLOTS
         DO 20 J=ISTART+1,ISTART+NPTS(I)
            IF(PTS(1,J).LT.X1) X1=PTS(1,J)
            IF(PTS(1,J).GT.X2) X2=PTS(1,J)
            IF(PTS(2,J).LT.Y1) Y1=PTS(2,J)
            IF(PTS(2,J).GT.Y2) Y2=PTS(2,J)
   20    CONTINUE
         ISTART = ISTART+NPTS(I)
   30 CONTINUE
C
C     PLOT POINTS IN PTS ARRAY ON A MATRIX
C
      ISTART=0
      DO 50 I=1,NPLOTS
         DO 40 J=ISTART+1,ISTART+NPTS(I)
            II=(PTS(1,J)-X1)*(JU-1)/(X2-X1)+1
            IF(II.LT.1) II=1
            IF(II.GT.26) II=26
            JJ=(PTS(2,J)-Y1)*(IU-1)/(Y2-Y1)+1
            IF(JJ.LT.1) JJ=1
            IF(JJ.GT.51) JJ=51
            JJ=52-JJ
   40       A(JJ,II)=XCHARS(I)
         ISTART=ISTART+NPTS(I)
   50 CONTINUE
C
C    PRINT A MATRIX
C
      IF (OUNIT .LE. 0) RETURN
      WRITE(OUNIT,1)
    1 FORMAT(
     *'1 PLOTS OF ARRAY X-AXIS    MIN     MAX    Y-AXIS    MIN     MAX')
      WRITE(OUNIT,2)(XCHARS(J),LABELS(1,J),X1,X2,LABELS(2,J),Y1,Y2,
     *           J=1,NPLOTS)
    2 FORMAT(11X,A1,5X,A4,2F10.4,2X,A4,2F10.4)
      WRITE(OUNIT,4)
    4 FORMAT('0')
      WRITE(OUNIT,5)
    5 FORMAT(10X,106('-'))
      WRITE(OUNIT,6)((A(I,J),J=1,26),I=1,51)
    6 FORMAT(10X,'''',26A4,'''')
      WRITE(OUNIT,5)
      RETURN
      END
