        INCLUDE 'MISCIOFI.FOR'
        INCLUDE 'STDHDR.FOR'
	REAL	rr, rand
	REAL xdata(0: maxv), ydata(0: maxv)
	REAL y2data(0: maxv),y3data(0: maxv)
	CHARACTER * 80	 pathname, titlex, titley, titlew
	INTEGER   plottype, i , chnum
        CHARACTER ch, scancode



	 DO i = 0, 50
	   rr = i + 1
	   xdata(i) = rr
           CALL Random(rand)
	   ydata(i) = rr**2 * rand
	   y2data(i) = 1000.0+((2.0*rand)/2.0)*1000*COS(rr/2.0)
	   y3data(i) = 3000.0*(1.0-EXP(-rr/10.0))*(4.0-rand)/4.0
	 END DO
	 pathname = 'c:\FOR\LIB\*.FON'
	 CALL InitSEGraphics(-1,pathname)
         CALL NoCursor()
	 CALL SetPercentWindow(0.01, 0.01, 0.255, 0.22, 6)
	 CALL SetPercentWindow(0.26, 0.01, 0.505, 0.22, 7)
	 CALL SetPercentWindow(0.51, 0.01, 0.755, 0.22, 8)
	 CALL SetPercentWindow(0.76, 0.01, 0.99, 0.22, 9)

	 CALL SetCurrentWindow(6)
	 CALL BorderCurrentWindow(1)
	 CALL SetWin2PlotRatio(6, 0.2, 0.2, 0.05, 0.2)
	 CALL ScalePlotArea(0.0, 0.0, 50.0, 3000.0)
	 CALL SelectColor(15)
	 CALL SetXYIntercepts(0.0, 0.0)
	 titlew = 'SIGNAL #1'
	 titlex = 'FREQ.'
	 titley = 'MAG'
	 CALL TitleWindow(titlew)
	 CALL TitleXAxis(titlex)
	 CALL TitleYAxis(titley)
	 CALL SelectColor(1)
	 CALL DrawYAxis(500.0, 0)
	 CALL DrawXAxis(10.0, 0)
	 CALL LinePlotData(xdata, ydata, 50, 2, 0)

	 CALL SetCurrentWindow(7)
	 CALL BorderCurrentWindow(1)
	 CALL SetWin2PlotRatio(7, 0.2, 0.2, 0.05, 0.2)
	 CALL ScalePlotArea(0.0, 0.0, 30.0, 3000.0)
	 CALL SetXYIntercepts(0.0,0.0)
	 CALL SelectColor(1)
	 CALL DrawYAxis(500.0, 0)
	 CALL DrawXAxis(10.0, 0)
	 CALL SelectColor(15)
	 titlew = 'SIGNAL #2'
	 CALL TitleWindow(titlew)
	 CALL TitleXAxis(titlex)
	 CALL TitleYAxis(titley)
	 CALL LinePlotData(xdata, y2data, 50, 2, 1)

	 CALL SetCurrentWindow(8)
	 CALL BorderCurrentWindow(1)
	 CALL SetWin2PlotRatio(8, 0.2, 0.2, 0.05, 0.2)
	 CALL ScalePlotArea(0.0, 0.0, 50.0, 3000.0)
	 CALL SetXYIntercepts(0.0, 0.0)
	 CALL SelectColor(1)
	 CALL DrawYAxis(500.0, 0)
	 CALL DrawXAxis(10.0, 0)
	 CALL SelectColor(15)
	 titlew = 'SIGNAL #3'
	 CALL TitleWindow(titlew)
	 CALL TitleXAxis(titlex)
	 CALL TitleYAxis(titley)
	 CALL ScatterPlotData(xdata, y3data, 50, 2, 1)

	 CALL SetCurrentWindow(9)
	 CALL BorderCurrentWindow(1)
	 CALL SetWin2PlotRatio(9, 0.2, 0.2, 0.05, 0.2)
	 CALL ScalePlotArea(25.0, 0.0, 50.0, 2000.0)
	 CALL SetXYIntercepts(25.0, 0.0)
	 CALL SelectColor(1)
	 CALL DrawYAxis(500.0, 0)
	 CALL DrawXAxis(10.0, 0)
	 CALL SelectColor(15)
	 titlew = 'SIGNAL #4'
	 CALL TitleWindow(titlew)
	 CALL TitleXAxis(titlex )
	 CALL TitleYAxis(titley)
	 CALL LinePlotData(xdata, ydata, 50, 2, 0)

	 CALL SetPercentWindow(0.0, 0.25, 0.99, 0.8, 4)
	 CALL SetWin2PlotRatio(4, 0.17, 0.14, 0.05, 0.2)
	 CALL SetPercentWindow(0.0, 0.85, 0.99, 0.95, 1)

	 CALL SetCurrentWindow(4)
	 CALL ClearWindow
	 CALL SetAxesType(1, 1)
	 CALL SelectColor(7)
	 CALL AutoAxes(xdata, ydata, 50, 0)
	 CALL LinePlotData(xdata, ydata, 50, 3, 1)
	 CALL SelectColor(1)
	 titlew =  'SEMI-LOG PLOT'
	 titlex =  'FREQUENCY'
	 titley =  'MAGNITUDE'
	 CALL TitleWindow(titlew)
	 CALL TitleXAxis(titley)
	 CALL TitleYAxis(titley)
	 CALL BorderCurrentWindow(1)
	 CALL SetLineStyleXX(1, 0, 0 )
	 CALL DrawGridX(1)
	 CALL DrawGridY(1)

	 chnum = 1
	 DO WHILE ( chnum .NE. 0)
	   CALL SetCurrentWindow(1)
	   CALL ClearWindow
	   CALL SetLineStyleXX(0, 0, 0)
	   CALL BorderCurrentWindow(1)
	   CALL LabelGraphWindow(10.0, 600.0,
     +	   'Graph Type <1-3> or 0 to Quit  ', 0, 0)
	   CALL LabelGraphWindow(10.0, 200.0,
     +	   'GRAPH TYPE:   1-LINE-PLOT  2-SCATTER-PLOT  3-BAR-GRAPH',
     +       0, 0)
           CALL MoveToXX(400.0, 200.0)
	   CALL ReadKey(ch,scancode)
           chnum = ICHAR(ch) - 48
c	   CALL LabelGraphWindow(900.0, 200.0, ch, 0, 0)
	   IF (chnum .GE. 1 .AND. chnum .LE. 3) THEN
  	     CALL ClearWindow
	     CALL BorderCurrentWindow(1)
	     plottype = chnum
	     CALL LabelGraphWindow(10.0, 600.0,
     +         'Enter Axis Type <1-3> ', 0, 0)
	     CALL LabelGraphWindow(10.0, 200.0,
     +	   'AXES TYPE:    1-AUTO-LIN  2-AUTO-SEMILOG  3-AUTO-LOG',0,0)
 	   CALL ReadKey(ch,scancode)
           chnum = ICHAR(ch) - 48
c           CALL RealString(REAL(ch), 0, 1, Tch)
c           CALL LabelGraphWindow(900.0, 200.0, Tch, 0, 0)

	     CALL SetCurrentWindow(4)
	     CALL ClearWindow
	     SELECT CASE (chnum)
	       CASE (1)
	         CALL SetAxesType(0, 0)
               CASE (2)
                 CALL SetAxesType(0, 1)
	       CASE (3)
                 CALL SetAxesType(1, 1)
	     END SELECT
	     CALL SelectColor(7)
	     CALL AutoAxes(xdata, ydata, 50, 0)
	     SELECT CASE (plottype)
	     CASE (1)
		 CALL LinePlotData(xdata, ydata, 50, 3, 1)
	     CASE (2)
		 CALL ScatterPlotData(xdata, ydata, 50, 3, 1)
	     CASE (3)
		 CALL BarGraphData(xdata, ydata, 50, 0.5, 3, 2)
	      END SELECT
	      CALL SelectColor(1)
	      IF (chnum .EQ. '1') THEN
	         titlew = 'LINEAR PLOT'
	      ELSEIF (chnum .EQ. '2') THEN
	        titlew = 'SEMI-LOG PLOT'
	      ELSE
		titlew = 'LOG PLOT'
	      END IF
	      CALL TitleWindow( titlew )
	      CALL TitleXAxis(titlex)
	      CALL TitleYAxis(titley)
	      CALL BorderCurrentWindow(1)
	      CALL SetLineStyleXX(0, 0, 0)
	      IF (chnum .EQ. 1)  CALL DrawGridY(10)
           END IF
	 END DO
	 CALL CloseSEGraphics

	 END
