1 This is a primer for PLOT2 (SHARE;PLOT2 PRIMER). Please look at
2 SHARE;PLOT2 USAGE for full documentation of PLOT2. (Last revision of
3 this file: August 1981.)
5 This file contains the "Easy Examples" excerpted from PLOT2 USAGE.
6 You will quite likely be able to figure out what's going on just
7 from these examples. Only read the relevant section later, if
8 something is unclear. To see the general capabilities of PLOT2 do
9 DEMO(PLOT2,DEMO,DSK,SHARE); (type spaces after the plots) and
10 most of these examples will be tried.
13 PLOT2(SIN(X),X,-%PI,%PI); plots sin(X) against X as X takes on
14 PLOTNUM values between -%PI to %PI
15 PLOT2(X!,X,0,6,INTEGER); plots X! as X takes integral values
18 PLOT2(F(X),X,[-2,3,100.12]); plots F(X) as X takes the values in
19 the values in the list
20 PLOT2([X+1,X^2+1],X,-1,1); plots 2 curves on top of each other
22 GRAPH2([1,2,3],[5,10,6]); draws a line connecting [1,5], [2,10],
25 PARAMPLOT2(COS(T),SIN(T),T,0,2*%PI); Plots cos(T) for the x-axis and
26 sin(T) for the y-axis as T takes on PLOTNUM (Sec 1.5) values
27 between 0 and 2*%PI. (If EQUALSCALE is TRUE (Sec 8.3) this
30 LOAD('[WORLD,FASL,DSK,SHARE]);
31 WORLDPLOT(-15, 10, 48, 60); draws a map of the United Kingdom.
33 PLOT3D(EXP(-X^2-Y^2)*X,X,-2,2,Y,-1.5,2.5); Plots exp(-X^2-Y^2)*X as
34 X takes on PLOTNUM values between -2 and 2 and y takes on
35 PLOTNUM1 values between -1.5 and 2.5
36 TRANSLATE:TRUE; causes automatic translation
37 G(X,Y):=(MODEDECLARE([X,Y],FLOAT),EXP(-X*X-Y*Y)); define a function G
38 PLOT3D(G,-2,2,-2,2); plot it
40 PLOT3D(SIN(X)+A,X,-%PI,%PI,A,[-2,3,4,6],NOT3D); plots sin(X)+A
41 for X from -%PI to %PI (PLOTNUM points) and A taking the
42 values in the list. This is equivalent to:
43 PLOT2([SIN(X)-2,SIN(X)+3,SIN(X)+4,SIN(X)+6],X,-%PI,%PI);
44 but requires less typing.
46 CONTOURS:10; Do 10 contours
47 LABELCONTOURS:FALSE; Don't label the contours
48 CONTOURPLOT2(Y^2/2+COS(X)+X/2,X,-6,6,Y,-3,3); Do a contour
49 plot of Y^2/2+cos(X) as X takes PLOTNUM values between -6
50 and 6 and as Y takes PLOTNUM1 values between -3 and 3.
51 (This gives you the phase space orbits of a particle in a
52 periodic potential superimposed on a constant field).
53 PLOT3D(Y^2/2+COS(X)+X/2,X,-6,6,Y,-3,3,CONTOUR); The same
54 CONTOURS:[0]; Plot only the zero contour.
55 CONTOURPLOT2([REALPART((X+%I*Y)^3-1),IMAGPART((X+%I*Y)^3-1)],
56 X,-1.5,1.5,Y,-1.5,1.5,[0,1]); Finds the zeroes of Z^3=-1 in
58 CONTOURS:PLOTNUM:PLOTNUM1:10; Work with a 10x10 grid
59 CONTOURPLOT2(RANDOM(100),X,0,1,Y,0,1); Plot something random
61 PLOT2(1,X,0,2*%PI); Plots a straight line
62 REPLOT(TRUE,POLAR); Plots it in polar coordinates (Sec 13.1). This
63 will appear as an ellipse unless EQUALSCALE:TRUE (Sec 8.3)
65 REPLOT(); Replots the ellipse with EQUALSCALE equal to
66 TRUE; this will then appear as a circle.
68 PLOTMODE(DISPLAY,XGP); Set things up for plotting on the XGP
71 PLOT2(EXP(X),X,0,3,X,EXP(X),"THIS IS A PLOT OF EXP(X) VS. X");
72 plots a curve of exp(X) with an x-label of "X", a y-label of
73 "EXP(X)" and a tile of "THIS IS A PLOT OF EXP(X) VS. X" (the
74 labels don't appear with the "'s)
76 PLOT2(SIN(X)+A,X,-%PI,%PI,FALSE,FALSE,LABEL(A));
77 plots sin(X)+A and sticks an the title "A=3".
78 PLOT2(SIN(X),X,-%PI,%PI,FALSE,SIN(X)); labels the y-axis with
81 PLOT2([SIN(X),COS(X)],X,-%PI,%PI,[0,1]); Plots sin(X) with line
82 type 0 (a solid line) and cos(X) with line type 1 (a dashed
84 PARAMPLOT2(RANDOM(),RANDOM(),X,0,1,[19]); Plots PLOTNUM
85 "random" points with symbol 1 (no connecting lines drawn)
86 TT:[0,1,2,3,4,5,6,7,8];
88 PLOT3D(SIN(X)+A,X,-%PI,%PI,A,0,2,TT,NOT3D); Gives the full
89 repertory of line types
90 TT:9+10*(TT+1); TT is now [19,29,39 ... ]
91 REPLOT(TRUE,TT); Gives the full repertory of symbol types.
93 PLOT2(1,T,0,2*%PI,POLAR); Plots a circle
94 REPLOT(TRUE,LIN); Replots the previous plot on a linear
95 scale (i.e., gives a horizontal line)
96 PLOT2(EXP(X),X,0,10,LINLOG); Plots exp(X) on a Lin-Log scale
97 (appears as a straight line)
98 GRAPH2([1,2,5,10,50,100],[1,1.5,2.5,3,7,10],LOG); Plots some
99 random points on Log-Log scale. Slope shows that y=sqrt(x).