      SUBROUTINE YAXIS(LABY,IG)
C
      COMMON /CRD/AUSX,BUSX,AUSY,BUSY,ASUX,BSUX,ASUY,BSUY,AMSX,BMSX
     1,ASMX,BSMX,AUMX,BUMX,AMUX,BMUX,DSP,ITERM,N,NS,NF
      COMMON /SCN/ XS,XF,YS,YF,XXS,XXF,YYS,YYF,CSTR,CFIN,CYMIN,CYMAX,STR
     1,FIN,YMIN,YMAX,ZZ,CW,CH,ISP,JSP,IFL
C
      BYTE LABY(8),ZERO,DOT,ONE,ZF(5),TIMES
      BYTE ISP,JSP,DSP,IG,ITERM,IFL
C
      IF(ISP.EQ.3.AND.IFL.GT.2) RETURN  ! NO YAXIS  OVERLAY
      EX=1.0
C    YD USER SPECIFIED DISPLACEMENT
C
      ZERO='0'
      DOT='.'
      ONE='1'
      TIMES='X'
      ZMAX=CYMAX
      IF(ABS(CYMIN).GT.CYMAX) ZMAX=ABS(CYMIN)*10.
      Y=YYF - 3*CH
      IF(ISP.EQ.2.AND.JSP.EQ.0)Y=YYF + YD
      XST=XS
      DO 10 I=1,8
      CALL TPLOT(2,XST,Y)
      CALL OUTPUT(LABY(I),1)
   10 Y=Y-CH
C WRITE MULTIPLIER
      IF(ZMAX.LT.99.0) GO TO 90
      IF(ZMAX.GT.32000.) GO TO 21
      II=0
      GO TO 91
   21 IF(ZMAX.GT.320000.) GO TO 24
      EX=10.0
      II=1
      GO TO 30
   24 IF(ZMAX.GT.3200000.) GO TO 25
      EX=100.
      II=2
      GO TO 30
   25 IF(ZMAX.GT.32000000.) GO TO 26
      EX=1000.0
      II=3
      GO TO 30
   26 EX=10000.0
      II=4
      GO TO 30
   90 IF(ZMAX.GT.1.0) GO TO 91
      EX=0.1
      II=6
   30 IF(ISP.EQ.2.AND.IFL.GT.2) GO TO 91 ! SPLIT SCREEN
      Y=Y-2*CH
      CALL TPLOT(2,XST,Y)
      CALL OUTPUT(TIMES,1)
      Y=Y-2*CH
      GO TO (16,15,14,13,12,11) II
   11 CALL TPLOT(2,XST,Y)
      CALL OUTPUT(ZERO,1)
      Y=Y-CH
   12 CALL TPLOT(2,XST,Y)
      CALL OUTPUT(ZERO,1)
      Y=Y-CH
   13 CALL TPLOT(2,XST,Y)
      CALL OUTPUT(ZERO,1)
      Y=Y-CH
   14 CALL TPLOT(2,XST,Y)
      CALL OUTPUT(ZERO,1)
      Y=Y-CH
   15 CALL TPLOT(2,XST,Y)
      CALL OUTPUT(ZERO,1)
      Y=Y-CH
   16 CALL TPLOT(2,XST,Y)
      CALL OUTPUT(ZERO,1)
      Y=Y-CH
      CALL TPLOT(2,XST,Y)
      CALL OUTPUT(DOT,1)
      Y=Y-CH
      CALL TPLOT(2,XST,Y)
      CALL OUTPUT(ONE,1)
   91 CONTINUE
C PLOT YAXIS
      IF(IG.EQ.1)GO TO 1
      CALL TPLOT(0,XXS,YYS)
      CALL TPLOT(1,XXS,YYF)
    1 X=XXS
      X1=X-4.
      X2=X+4.
      IFLAG=1
      DYY=(YYF - YYS)/10.0
      DO 70 I=1,11
      YY=I - 1
      Y=YYS + YY*DYY
      IF(IFLAG.EQ.1.AND.IG.EQ.1) GO TO 71
      CALL TPLOT(0,X1,Y)
      CALL TPLOT(1,X2,Y)
      IFLAG=1
      GO TO 70
   71 CALL TPLOT(0,XXS,Y)
      CALL TPLOT(1,XXF,Y)
      IFLAG=0
   70 CONTINUE
      X=X-6*CW+4
      DY=(CYMAX - CYMIN)/10.0
      DO 78 I=1,6
      YY=(I - 1)*2
      Y=YYS + (YY*DYY) -9.
C  FOR RT-11 VERSION -9. IS USED FOR RSX-11M USE +12.
      CALL TPLOT(2,X,Y)
      YYY=(DY*YY+CYMIN)/EX
      IF(CYMAX.LT.100.0) GO TO 100
      J=YYY+.5
      ENCODE(5,72,ZF) J
   72 FORMAT(I5)
      GO TO 74
  100 IF(YYY.LT.-0.0) GO TO 80
      ENCODE(5,77,ZF) YYY
   77 FORMAT(F5.2)
      GO TO 74
   80 IF(YYY.LT.-99.9) GO TO 81
      ENCODE(5,75,ZF) YYY
   75 FORMAT(F5.0)
      GO TO 74
   81 IF(YYY.LT.-999.0) GO TO 74
      IF(YYY.LT.-9999.0) GO TO 78
      II=YYY
      ENCODE(5,76,ZF) II
   76 FORMAT(I5)
   74 CALL OUTPUT(ZF,5)
   78 CONTINUE
      RETURN
      END
