      Subroutine Cvplot
c ***********************************************************************
c *                                                                     *
c *        Subroutine CVPLOT - To plot a curve on the plotting area.    *
c *        This subroutine also plots symbols at the datapoints, if     *
c *        the user has selected that option.                           *
c *                                                                     *
c *          Programmed by Steven C. Fisher, DTNSRDC Code 1522          *
c *                                                                     *
c ***********************************************************************
c
      Parameter (Nptmax = 300)
      Dimension Xvals(Nptmax),Yvals(Nptmax)
      Dimension X(Nptmax),Y(Nptmax)
      Dimension Xmin(2),Ymin(2),Xmax(2),Ymax(2),Xinc(2),Yinc(2)
      Integer Xnumbr,Ynumbr,Axchst,Axtypx,Axtypy,Axcolr,Ticdir,
     $     Atxclr
      Dimension Color(20),Crvfit(20),Cvsymb(20),Cvline(20),Xcvaxi(20),
     $          Ycvaxi(20),Npt(20)
      Byte Xaxi(2,80),Yaxi(2,80)
c
      Dimension Lt(10),Triang(8)
      Data Lt/1,22,52,5222,11,4444,7242,1414,7111,9252/
      Data Triang/3.0,0.0,0.0,0.5,-0.5,-0.577,0.289,0.289/
      Integer Color,Crvfit,Cvsymb,Cvline,Xcvaxi,Ycvaxi
c
      Common/Axis/Xmin,Xmax,Ymin,Ymax,Xinc,Yinc,Xlen,Ylen,Xnumbr,
     $ Ynumbr,Xaxi,Yaxi,Axthik,Axchst,Axtypx,Axtypy,Axcolr,Textsz,
     $ Ticdir,Atxclr
c
c           Read the curve parameters
c
      Call Cparam(Ncurve,Npt,Color,Crvfit,Cvsymb,Cvline,
     $           Xcvaxi,Ycvaxi,Symbsz,Cvthik)
c
      Call Stlthc(Cvthik)
      Call Stsysz(Symbsz)
      Call Stclon
c
c           Start looping over the curves
c
      Do 20 I=1,Ncurve
c
         Np = Npt(I)
c
c           Read the curve data
c
         Call Incrv(X,Y,Np)
c
c           Sort the points before plotting
c
         If (Crvfit(I) .NE. 6) Call Sort(X,Y,Np)
c
c           Set the plot coordinate frame
c
         Xn = Xcvaxi(I)
         If (Xnumbr .EQ. 1) Xn = 1
         Yn = Ycvaxi(I)
         If (Ynumbr .EQ. 1) Yn = 1
c
         Call Plwin(Xmin(Xn),Xmax(Xn),Ymin(Yn),Ymax(Yn),Xlen,Ylen)
c
c            Compute the X values
c
         Numbr = 300
         Xink = (X(Np) - X(1)) / (Numbr - 1)
         Do 5 J=1,Numbr
            Xvals(J) = X(1) + (J-1) * Xink
 5       Continue
c
c          Set the symbol type, and plot the symbols
c
         Call Stlint(0)
         If (Axtypx .EQ. 2) Call Stlogx   ! For logrithmic axes
         If (Axtypy .EQ. 2) Call Stlogy
c
         If (Cvsymb(I) .GT. 0) Then
c
            Call Stsyco(Color(I))
            If (Cvsymb(I) .LE. 10) Then
               Call Stsyty(10+Cvsymb(I))
            Else If (Cvsymb(I) .GT. 11) Then
               Call Stsyty(Cvsymb(I)-10)
            End If
c
            Do 10 J=1,Np
               If (Cvsymb(I) .NE. 11) Then
                  Call Wcsymb(X(J),Y(J))
               Else
                  Call Wcsymd(X(J),Y(J),Triang)
               End If
 10         Continue
         End If
c
c           Set the curve line type
c
         Call Stlint(Lt(Cvline(I)))
c
c          Compute the interpolated data (depending upon the fit used)
c
         Icheck = Crvfit(I)
         If (Icheck .EQ. 1) Then
c
c           Straight line fit
c
            Do 40 J=1,Np
               Xvals(J) = X(J)
               Yvals(J) = Y(J)
 40         Continue
            Numbr = Np
c
         Else If (Icheck .LT. 0) Then
c
c             Least squares fit
c
           Iorder = -Icheck
            Call Lsqplt(Xvals,Yvals,Numbr,X,Y,Np,Iorder)
c           Call Lsqfit(X,Y,Np,Iorder,Coefs)
c           Call Lseval(Xvals,Yvals,Numbr,Iorder,Coefs)
c
         Else If (Icheck .EQ. 3) Then
c
c            Cubic spline fit
c
             Call Csplot(Xvals,Yvals,Numbr,X,Y,Np)
c            Call Csplin(X,Y,Np,Coefs)
c            Call Cseval(Xvals,Yvals,Numbr,X,Y,Np,Coefs)
c
         Else If (Icheck .GT. 3 .AND. Icheck .LT. 7) Then
c
c            Parametric spline fit
c
            Itype = 1
            If (Icheck .EQ. 5) Itype = 2
            Call Psplot(Xvals,Yvals,Numbr,X,Y,Np,Itype)
c
         Else If (Icheck .GE. 7) Then
            Call Lsqseg(Xvals,Yvals,Numbr,X,Y,Np,Icheck-6)
         End If
c
c          Plot out the data values
c          Set the colors
c
         Call Stplco(Color(I))
c
         If (Icheck .NE. 0) Call Wccurv(Xvals,Yvals,Numbr)
c
 20   Continue
c
      Return
      End
