Silverfrost Logo About Us | Contact Us
 

Plotting x = x(t), y = y(t)

The following code is extracted from program simdem10 in the Simdem package, and it illustrates how easy it is to plot a curve in the parametric form x = x(t), y = y(t), where x and y are double precision arrays. Of course, the arrays x, and y do not need to be in parameteric form, and any number of up to 4 x,y pairs in the form y = f(x) can be plotted. Setting l(i) = m(i) = 0 suppresses the plotting of y(i).


c
c Define line and symbol types and number of points
c      
      l1 = 1     !solid line type
      l2 = 2     !dashed line type
      l3 = 3     !dotted line type
      l4 = 4     !dashed-dotted line type
      m1 = 5     !circle symbol type 
      m2 = 8     !triangle symbol type
      m3 = 11    !square symbol type
      m4 = 14    !diamond symbol type
      n = nmax/2 !numer of points for plotting
      n1 = n
      n2 = n
      n3 = n
      n4 = n 
c
c Define the data
c      
      delta = pi2/(dble(n) - one)
      t(1) = zero
      do i = 2, n - 1
         t(i) = t(i - 1) + delta
      enddo
      t(n) = pi2
      do i = 1, n
         cosi = cos(t(i))
         sini = sin(t(i))
         x1(i) = a*cosi
         x2(i) = b*cosi
         x3(i) = c*cosi
         x4(i) = d*cosi
         y1(i) = a*sini
         y2(i) = b*sini
         y3(i) = c*sini
         y4(i) = d*sini
      enddo
c
c Define the title and legends
c      
      ptitle = 'y = f(x)'
      xtitle = 'x'
      ytitle = 'y'            
c
c Plot the graphs
c      
      call gks004 (l1, l2, l3, l4,
     +             m1, m2, m3, m4,
     +             n1, n2, n3, n4,
     +             x1, x2, x3, x4,
     +             y1, y2, y3, y4,
     +             ptitle, xtitle, ytitle,
     +             axes, gsave)

The following plot is then displayed and can be edited to add further features, printed, or archived as a graphics file.

 

 

Copyright © 1999-2017 Silverfrost Limited