home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / rexxplpt.lzh / REXXPLPLOT / EXAMPLES / EXAMPLE01.PLOT < prev    next >
Text File  |  1991-08-16  |  2KB  |  104 lines

  1. /* Example01.Plot - Demonstration program for PLPLOT: */
  2. /* Modified for RexxPlPlot by Glenn M. Lewis - 9/12/89 */
  3.  
  4. address 'PlPlot'
  5. say 'Please be patient...'
  6.  
  7. /* Plots three simple functions, each function occupies a separate page */
  8.  
  9. do i=1 to 6
  10.     xs.i = i
  11.     ys.i = i * i
  12. end i
  13.  
  14. space0 = 0
  15. mark0  = 0
  16. space1 = 1500
  17. mark1  = 1500
  18.  
  19. /* Ask user to specify the output device */
  20.  
  21.       'plstar(1,1);'
  22.  
  23. /* Set up the viewport and window using PLENV. The range in X is */
  24. /* 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are */
  25. /* scaled separately (just = 0), and we just draw a labelled */
  26. /* box (axis = 0). */
  27.  
  28.       'plenv(0.0,6.0,0.0,30.0,0,0);'
  29.       'pllab("(x)","(y)","\frPLPLOT Example 1 - y=x\u2");'
  30.  
  31. /* Plot the data points */
  32.  
  33.       'plpoin(6,xs,ys,9);'
  34.  
  35.       do i=1 to 60
  36.         x.i = 0.1*i;
  37.         y.i = pow(x.i,2.0);
  38.       end i
  39.  
  40. /* Draw the line through the data */
  41.  
  42.       'plline(60,x,y);'
  43.  
  44. /*======================================================================*/
  45.  
  46. /* Set up the viewport and window using PLENV. The range in X is */
  47. /*  -2.0 to 10.0, and the range in Y is -0.4 to 2.0. The axes are */
  48. /*  scaled separately (just = 0), and we draw a box with axes */
  49. /*  (axis = 1). */
  50.  
  51.       'plenv(-2.0,10.0,-0.4,1.2,0,1);'
  52.       'pllab("(x)","sin(x)/x","\frPLPLOT Example 1 - Sinc Function");'
  53.  
  54. /* Fill up the arrays */
  55.  
  56.       do i=1 to 100
  57.         x.i = (i-20.0)/6.0
  58.         y.i = 1.0
  59.         if (x.i ~= 0.0) then y.i = sin(x.i)/x.i
  60.       end i
  61.  
  62. /* Draw the line */
  63.  
  64.       'plline(100,x,y);'
  65.  
  66. /*======================================================================*/
  67.  
  68. /* For the final graph we wish to override the default tick intervals, */
  69. /* and so do not use PLENV */
  70.  
  71.       'pladv(0);'
  72.  
  73. /* Use standard viewport, and define X range from 0 to 360 degrees, */
  74. /* Y range from -1.2 to 1.2. */
  75.  
  76.       'plvsta();'
  77.       'plwind(0.0,360.0,-1.2,1.2);'
  78.  
  79. /* Draw a box with ticks spaced 30 degrees apart in X, and 0.2 in Y. */
  80.  
  81.       'plbox("bcnst",30.0,3,"bcnstv",0.2,2);'
  82.  
  83. /* Superimpose a dashed line grid, with 1.5 mm marks and spaces. */
  84. /* plstyl expects a pointer!! */
  85.  
  86.       'plstyl(1, mark1, space1);'
  87.       'plbox("g",30.0,3,"g",0.2,2);'
  88.       'plstyl(0, mark0, space0);'
  89.  
  90.       'pllab("Angle (degrees)","sine","\frPLPLOT Example 1 - Sine function");'
  91.  
  92.       do i=1 to 101
  93.         x.i = 3.6 * (i - 1);
  94.         y.i = sin(x.i*3.141592654/180.0);
  95.       end i
  96.  
  97.       'plline(101,x,y);'
  98.  
  99. /* Don't forget to call PLEND to finish off! */
  100.  
  101.       'plend();'
  102.  
  103. exit 0
  104.