PLOT10 Subroutine

public subroutine PLOT10(Y, X, Char, N, Ymin, Ymax, Xmin, Xmax, D, Dmin, Dmax, Yaxid, Xaxid, Plchid)

NAME

plot10(3f) - [M_datapac:GENERIC_LINE_PLOT] generate a line printer
plot with special plot characters

SYNOPSIS

   SUBROUTINE PLOT10( &
   & Y,X,Char,N,Ymin,Ymax,Xmin,Xmax,D,Dmin,Dmax,Yaxid,Xaxid,Plchid)

    REAL(kind=wp) :: Y(:)
    REAL(kind=wp) :: X(:)
    REAL(kind=wp) :: Char(:)
    INTEGER       :: N
    REAL(kind=wp) :: Ymin, Ymax
    REAL(kind=wp) :: Xmin, Xmax
    REAL(kind=wp) :: D(:)
    REAL(kind=wp) :: Dmin, Dmax
    REAL(kind=wp) :: Yaxid, Xaxid
    REAL(kind=wp) :: Plchid

DESCRIPTION

PLOT10(3f) yields a one-page printer plot of y(i) versus x(i):

 1. with special plot characters;
 2. with the vertical (y) axis min and max
    and the horizontal (x) axis min and max
    values specified by the data analyst;
 3. with only those points (x(i),y(i)) plotted
    for which the corresponding value of d(i)
    is between the specified values of dmin and dmax; and
 4. with hollerith labels (at most 6 characters)
    for the vertical axis variable,
    the horizontal axis variable, and
    the plotting character variable
    also being provided by the data analyst.

The 'special plotting character' capability allows the data analyst
to incorporate information from a third variable (aside from y and x)
into the plot.

The plot character used at the i-th plotting position (that is,
at the coordinate (x(i),y(i))) will be

  1 if char(i) is between  0.5 and  1.5
  2 if char(i) is between  1.5 and  2.5
    .
    .
    .
  9 if char(i) is between  8.5 and  9.5
  0 if char(i) is between  9.5 and 10.5
  a if char(i) is between 10.5 and 11.5
  b if char(i) is between 11.5 and 12.5
  c if char(i) is between 12.5 and 13.5
    .
    .
    .
  w if char(i) is between 32.5 and 33.5
  x if char(i) is between 33.5 and 34.5
  y if char(i) is between 34.5 and 35.5
  z if char(i) is between 35.5 and 36.5
  x if char(i) is any value outside the range 0.5 to  36.5.

The use of the ymin, ymax, xmin, and xmax specifications allows the
data analyst to control fully the plot axis limits, so as, for example,
to zero-in on an interesting sub-region of a previous plot.

The use of the subset definition vector d gives the data analyst
the capability of plotting subsets of the data, where the subset is
defined by values in the vector d.

The use of hollerith identifying labels allows the data analyst to
automatically have the plots labeled. this is particularly useful
in a large analysis when many plots are being generated.

Values in the vertical axis vector (Y) which are smaller than YMIN
or larger than YMAX, or values in the horizontal axis vector (X)
which are smaller than XMIN or larger than XMAX will not be plotted.

For a given dummy index I, if D(I) is smaller than DMIN or larger than
DMAX, then the corresponding point (X(I),Y(I)) will not be plotted.

Values in the vertical axis vector (Y), the horizontal axis vector
(X), or the plot character vector (CHAR) which are equal to or in
excess of 10.0**10 will not be plotted.

This convention greatly simplifies the problem of plotting when
some elements in the vector Y (or X, or CHAR) are 'missing data',
or when we purposely want to ignore certain elements in the vector Y
(or X, or CHAR) for plotting purposes (that is, we do not want certain
elements in Y (or X, or CHAR) to be plotted).

to cause specific elements in Y (or X, or CHAR) to be ignored,
we replace the elements beforehand (by, for example, use of the
REPLAC(3f) subroutine) by some large value (like, say, 10.0**10)
and they will subsequently be ignored in the PLOTC(3f) subroutine.

INPUT ARGUMENTS

Y       The vector of (unsorted or sorted) observations to be
        plotted vertically.
X       The vector of (unsorted or sorted) observations to be plotted
        horizontally.
CHAR    The vector of observations which control the value of each
        individual plot character.
N       The integer number of observations in the vector y.
        There is no restriction on the maximum value of n for this
        subroutine.
YMIN    The value of desired minimum for the vertical axis.
YMAX    The value of desired maximum for the vertical axis.
XMIN    The value of desired minimum for the horizontal axis.
XMAX    The value of desired maximum for the horizontal axis.
D       The vector which 'defines' the various possible subsets.
DMIN    The value which defines the lower bound (inclusively) of
        The particular subset of interest to be plotted.
DMAX    The value which defines the upper bound (inclusively) of
        The particular subset of interest to be plotted.
YAXID   The hollerith value (at most 6 characters) of the desired
        label for the vertical axis variable.
XAXID   The hollerith value (at most 6 characters) of the desired
        label for the horizontal axis variable.
PLCHID  The hollerith value (at most 6 characters) of the desired
        label for the plotting character variable.

OUTPUT

A one-page printer plot of Y(I) versus X(I), with special plot
characters, with specified axis limits, for only of a specified subset
of the data, and with specified labels.

EXAMPLES

Sample program:

program demo_plot10
use M_datapac, only : plot10
implicit none
! call plot10(x,y)
end program demo_plot10

Results:

AUTHOR

The original DATAPAC library was written by James Filliben of the
Statistical Engineering Division, National Institute of Standards
and Technology.

MAINTAINER

John Urban, 2022.05.31

LICENSE

CC0-1.0

REFERENCES

  • Filliben, ‘Statistical Analysis of Interlab Fatigue Time Data’, Unpublished Manuscript (available from Author) Presented at the ‘Computer-Assisted Data Analysis’ session at the National Meeting of the American Statistical Association, New York City, December 27-30, 1973.

Arguments

Type IntentOptional Attributes Name
real(kind=wp) :: Y(:)
real(kind=wp) :: X(:)
real(kind=wp) :: Char(:)
integer :: N
real(kind=wp) :: Ymin
real(kind=wp) :: Ymax
real(kind=wp) :: Xmin
real(kind=wp) :: Xmax
real(kind=wp) :: D(:)
real(kind=wp) :: Dmin
real(kind=wp) :: Dmax
real(kind=wp) :: Yaxid
real(kind=wp) :: Xaxid
real(kind=wp) :: Plchid

Common Blocks

HIST (subroutine)
PLOT6 (subroutine)
PLOT7 (subroutine)
PLOT8 (subroutine)
PLOT9 (subroutine)
PLOTC (subroutine)
PLOTCO (subroutine)
PLOT (subroutine)
PLOTSC (subroutine)
PLOTS (subroutine)
PLOTSP (subroutine)
PLOTU (subroutine)
PLOTX (subroutine)
PLOTXX (subroutine)
HIST (subroutine)
PLOT10 (subroutine)
PLOT6 (subroutine)
PLOT7 (subroutine)
PLOT8 (subroutine)
PLOT9 (subroutine)
PLOTC (subroutine)
PLOTCO (subroutine)
PLOT (subroutine)
PLOTSC (subroutine)
PLOTS (subroutine)
PLOTSP (subroutine)
PLOTU (subroutine)
PLOTX (subroutine)
PLOTXX (subroutine)
"> common /BLOCK1/

Type Attributes Name Initial
integer :: IGRaph(55,130)

Source Code

SUBROUTINE PLOT10(Y,X,Char,N,Ymin,Ymax,Xmin,Xmax,D,Dmin,Dmax,Yaxid,Xaxid,Plchid)
REAL(kind=wp) :: Y(:)
REAL(kind=wp) :: X(:)
REAL(kind=wp) :: Char(:)
INTEGER       :: N
REAL(kind=wp) :: Ymin, Ymax
REAL(kind=wp) :: Xmin, Xmax
REAL(kind=wp) :: D(:)
REAL(kind=wp) :: Dmin, Dmax
REAL(kind=wp) :: Yaxid, Xaxid
REAL(kind=wp) :: Plchid

REAL(kind=wp) :: aim1, cutoff, hold, ratiox, ratioy, x25, x75, xmid, ylable
INTEGER :: i, iarg, iflag, ip2, j, k, mx, my, n2
CHARACTER(len=4) :: IGRaph
CHARACTER(len=4) :: iplotc
CHARACTER(len=4) :: sbnam1 , sbnam2
CHARACTER(len=4) :: alph11 , alph12 , alph21 , alph22 , alph31 , alph32
CHARACTER(len=4) :: alph41 , alph42 , alph91 , alph92
CHARACTER(len=4) :: blank , hyphen , alphai , alphax
CHARACTER(len=4) :: alpham , alphaa , alphad , alphan , equal
!
DIMENSION ylable(11)
DIMENSION iplotc(37)
COMMON /BLOCK1/ IGRaph(55,130)
!
DATA sbnam1 , sbnam2/'PLOT' , '10  '/
DATA alph11 , alph12/'FIRS' , 'T   '/
DATA alph21 , alph22/'SECO' , 'ND  '/
DATA alph31 , alph32/'THIR' , 'D   '/
DATA alph41 , alph42/'FOUR' , 'TH  '/
DATA alph91 , alph92/'FIFT' , 'H   '/
DATA blank , hyphen , alphai , alphax/' ' , '-' , 'I' , 'X'/
DATA alpham , alphaa , alphad , alphan , equal/'M' , 'A' , 'D' ,  &
 &     'N' , '='/
DATA iplotc(1) , iplotc(2) , iplotc(3) , iplotc(4) , iplotc(5) ,  &
 &     iplotc(6) , iplotc(7) , iplotc(8) , iplotc(9) , iplotc(10) , &
 &     iplotc(11) , iplotc(12) , iplotc(13) , iplotc(14) ,          &
 &     iplotc(15) , iplotc(16) , iplotc(17) , iplotc(18) ,          &
 &     iplotc(19) , iplotc(20) , iplotc(21) , iplotc(22) ,          &
 &     iplotc(23) , iplotc(24) , iplotc(25) , iplotc(26) ,          &
 &     iplotc(27) , iplotc(28) , iplotc(29) , iplotc(30) ,          &
 &     iplotc(31) , iplotc(32) , iplotc(33) , iplotc(34) ,          &
 &     iplotc(35) , iplotc(36) , iplotc(37)/'1' , '2' , '3' , '4' , &
 &     '5' , '6' , '7' , '8' , '9' , '0' , 'A' , 'B' , 'C' , 'D' ,  &
 &     'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' ,  &
 &     'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' ,  &
 &     'Y' , 'Z' , 'X'/
!
      cutoff = (10.0_wp**10) - 1000.0_wp
!
!     CHECK THE INPUT ARGUMENTS FOR ERRORS
!
      WRITE (G_IO,99001)
99001 FORMAT ('1')
      IF ( N<1 ) THEN
         WRITE (G_IO,99016)
         WRITE (G_IO,99017)
         WRITE (G_IO,99019) alph41 , alph42 , sbnam1 , sbnam2
         WRITE (G_IO,99002) N
99002    FORMAT (' ','IS NON-NEGATIVE (WITH VALUE = ',I0,')')
         WRITE (G_IO,99016)
         RETURN
      ELSE
         IF ( N==1 ) THEN
            WRITE (G_IO,99016)
            WRITE (G_IO,99017)
            WRITE (G_IO,99019) alph41 , alph42 , sbnam1 , sbnam2
            WRITE (G_IO,99003) N
99003       FORMAT (' ','HAS THE VALUE 1')
            WRITE (G_IO,99016)
            RETURN
         ELSE
!
            hold = Y(1)
            DO i = 2 , N
               IF ( Y(i)/=hold ) GOTO 50
            ENDDO
            WRITE (G_IO,99016)
            WRITE (G_IO,99017)
            WRITE (G_IO,99019) alph11 , alph12 , sbnam1 , sbnam2
            WRITE (G_IO,99020) hold
            WRITE (G_IO,99016)
            RETURN
         ENDIF
 50      hold = X(1)
         DO i = 2 , N
            IF ( X(i)/=hold ) GOTO 100
         ENDDO
         WRITE (G_IO,99016)
         WRITE (G_IO,99017)
         WRITE (G_IO,99019) alph21 , alph22 , sbnam1 , sbnam2
         WRITE (G_IO,99020) hold
         WRITE (G_IO,99016)
         RETURN
      ENDIF
 100  hold = Char(1)
      DO i = 2 , N
         IF ( Char(i)/=hold ) GOTO 200
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99018)
      WRITE (G_IO,99019) alph31 , alph32 , sbnam1 , sbnam2
      WRITE (G_IO,99020) hold
      WRITE (G_IO,99016)
 200  hold = D(1)
      DO i = 2 , N
         IF ( D(i)/=hold ) GOTO 300
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99018)
      WRITE (G_IO,99019) alph91 , alph92 , sbnam1 , sbnam2
      WRITE (G_IO,99020) hold
      WRITE (G_IO,99016)
!
 300  DO i = 1 , N
         IF ( Y(i)<cutoff ) GOTO 400
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99017)
      WRITE (G_IO,99019) alph11 , alph12 , sbnam1 , sbnam2
      WRITE (G_IO,99021)
      WRITE (G_IO,99022) cutoff
      WRITE (G_IO,99016)
      RETURN
 400  DO i = 1 , N
         IF ( X(i)<cutoff ) GOTO 500
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99017)
      WRITE (G_IO,99019) alph21 , alph22 , sbnam1 , sbnam2
      WRITE (G_IO,99021)
      WRITE (G_IO,99022) cutoff
      WRITE (G_IO,99016)
      RETURN
 500  DO i = 1 , N
         IF ( Char(i)<cutoff ) GOTO 600
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99017)
      WRITE (G_IO,99019) alph31 , alph32 , sbnam1 , sbnam2
      WRITE (G_IO,99021)
      WRITE (G_IO,99022) cutoff
      WRITE (G_IO,99016)
      RETURN
 600  DO i = 1 , N
         IF ( D(i)<cutoff ) GOTO 700
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99017)
      WRITE (G_IO,99019) alph91 , alph92 , sbnam1 , sbnam2
      WRITE (G_IO,99021)
      WRITE (G_IO,99022) cutoff
      WRITE (G_IO,99016)
      RETURN
!
 700  DO i = 1 , N
         IF ( Dmin<D(i) .AND. D(i)<Dmax ) GOTO 800
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99017)
      WRITE (G_IO,99019) alph91 , alph92 , sbnam1 , sbnam2
      WRITE (G_IO,99004)
99004 FORMAT (' ','HAS ALL ELEMENTS OUTSIDE THE INTERVAL')
      WRITE (G_IO,99005) Dmin , Dmax
99005 FORMAT (' ','(',E15.8,',',E15.8,')',' AS DEFINED BY')
      WRITE (G_IO,99006)
99006 FORMAT (' ','THE TENTH  AND ELEVENTH INPUT ARGUMENTS.')
      WRITE (G_IO,99016)
      RETURN
!
 800  n2 = 0
      DO i = 1 , N
         IF ( Y(i)<cutoff .AND. X(i)<cutoff .AND. Char(i)<cutoff .AND. D(i)<cutoff ) THEN
            IF ( Dmin<D(i) .AND. D(i)<Dmax ) n2 = n2 + 1
            IF ( n2>=2 ) GOTO 900
         ENDIF
      ENDDO
      WRITE (G_IO,99016)
      WRITE (G_IO,99017)
      WRITE (G_IO,99007) alph11 , alph12 , alph21 , alph22 , alph31 , alph32 , alph91 , alph92
99007 FORMAT (' ','THE ',A4,A4,', ',A4,A4,', ',A4,A4,', AND ',A4,A4)
      WRITE (G_IO,99008) sbnam1 , sbnam2
99008 FORMAT (' ','INPUT ARGUMENTS TO THE ',A4,A4,' SUBROUTINE')
      WRITE (G_IO,99009)
99009 FORMAT (' ','ARE SUCH THAT TOO MANY POINTS HAVE BEEN EXCLUDED FROM THE PLOT.')
      WRITE (G_IO,99010) n2
99010 FORMAT (' ','ONLY ',I0,' POINTS ARE LEFT TO BE PLOTTED.')
      WRITE (G_IO,99016)
      RETURN
!
!-----START POINT-----------------------------------------------------
!
!     DETERMINE THE VALUES TO BE LISTED ON THE LEFT VERTICAL AXIS
!
 900  DO i = 1 , 9
         aim1 = i - 1
         ylable(i) = Ymax - (aim1/8.0)*(Ymax-Ymin)
      ENDDO
!
!     DETERMINE THE VALUES TO BE LISTED ON THE BOTTOM HORIZONTAL AXIS
!     DETERMINE XMID, X25 (=THE 25% POINT), AND
!     X75 (=THE 75% POINT)
!
      xmid = (Xmin+Xmax)/2.0_wp
      x25 = 0.75_wp*Xmin + 0.25_wp*Xmax
      x75 = 0.25_wp*Xmin + 0.75_wp*Xmax
!
!     BLANK OUT THE GRAPH
!
      DO i = 1 , 45
         DO j = 1 , 109
            IGRaph(i,j) = blank
         ENDDO
      ENDDO
!
!     PRODUCE THE VERTICAL AXES
!
      DO i = 3 , 43
         IGRaph(i,5) = alphai
         IGRaph(i,109) = alphai
      ENDDO
      DO i = 3 , 43 , 5
         IGRaph(i,5) = hyphen
         IGRaph(i,109) = hyphen
      ENDDO
      IGRaph(3,1) = equal
      IGRaph(3,2) = alpham
      IGRaph(3,3) = alphaa
      IGRaph(3,4) = alphax
      IGRaph(23,1) = equal
      IGRaph(23,2) = alpham
      IGRaph(23,3) = alphai
      IGRaph(23,4) = alphad
      IGRaph(43,1) = equal
      IGRaph(43,2) = alpham
      IGRaph(43,3) = alphai
      IGRaph(43,4) = alphan
!
!     PRODUCE THE HORIZONTAL AXES
!
      DO j = 7 , 107
         IGRaph(1,j) = hyphen
         IGRaph(45,j) = hyphen
      ENDDO
      DO j = 7 , 107 , 25
         IGRaph(1,j) = alphai
         IGRaph(45,j) = alphai
      ENDDO
      DO j = 20 , 107 , 25
         IGRaph(1,j) = alphai
         IGRaph(45,j) = alphai
      ENDDO
!
!     DETERMINE THE (X,Y) PLOT POSITIONS
!
      ratioy = 40.0_wp/(Ymax-Ymin)
      ratiox = 100.0_wp/(Xmax-Xmin)
      DO i = 1 , N
         IF ( Y(i)<cutoff ) THEN
            IF ( X(i)<cutoff ) THEN
               IF ( Char(i)<cutoff ) THEN
                  IF ( Y(i)>=Ymin .AND. Y(i)<=Ymax ) THEN
                     IF ( X(i)>=Xmin .AND. X(i)<=Xmax ) THEN
                        IF ( D(i)>=Dmin ) THEN
                           IF ( D(i)<=Dmax ) THEN
                              mx = ratiox*(X(i)-Xmin) + 0.5_wp
                              mx = mx + 7
                              my = ratioy*(Y(i)-Ymin) + 0.5_wp
                              my = 43 - my
                              iarg = 37
                              IF ( 0.5_wp<Char(i) .AND. Char(i)<36.5_wp ) iarg = Char(i) + 0.5_wp
                              IGRaph(my,mx) = iplotc(iarg)
                           ENDIF
                        ENDIF
                     ENDIF
                  ENDIF
               ENDIF
            ENDIF
         ENDIF
      ENDDO
!
!     WRITE OUT THE GRAPH
!
      DO i = 1 , 45
         ip2 = i + 2
         iflag = ip2 - (ip2/5)*5
         k = ip2/5
         IF ( iflag/=0 ) WRITE (G_IO,99011) (IGRaph(i,j),j=1,109)
!
99011    FORMAT (' ',20X,109A1)
         IF ( iflag==0 ) WRITE (G_IO,99012) ylable(k) , (IGRaph(i,j),j=1,109)
99012    FORMAT (' ',F20.7,109A1)
      ENDDO
      WRITE (G_IO,99013) Xmin , x25 , xmid , x75 , Xmax
99013 FORMAT (' ',14X,F20.7,5X,F20.7,5X,F20.7,5X,F20.7,1X,F20.7)
      WRITE (G_IO,99014) Yaxid , Xaxid , Plchid
99014 FORMAT (' ',9X,A4,A4,' (VERTICAL AXIS) VERSUS ',A4,A4,' (HORIZONTAL AXIS) ',20X,'THE PLOTTING CHARACTER IS ',A4,A4)
      WRITE (G_IO,99015) N
99015 FORMAT (' ',83X,'THE NUMBER OF OBSERVATIONS PLOTTED IS ',I0)
!
99016 FORMAT (' ','**********************************************************************')
99017 FORMAT (' ','                   FATAL ERROR                    ')
99018 FORMAT (' ','               NON-FATAL DIAGNOSTIC               ')
99019 FORMAT (' ','THE ',A4,A4,' INPUT ARGUMENT TO THE ',A4,A4,' SUBROUTINE')
99020 FORMAT (' ','HAS ALL ELEMENTS = ',E15.8)
99021 FORMAT (' ','HAS ALL ELEMENTS IN EXCESS OF THE CUTOFF')
99022 FORMAT (' ','VALUE OF ',E15.8)
!
END SUBROUTINE PLOT10