In [ ]:
load 'plot'
This loads the package into locale plot, and defines two user functions, "pd" (Plot Driver) and "plot".
pd - low-level function that handles all calls to Plot, typically used for complex plots.
plot - cover function for pd that will handle most simple uses of Plot.
The examples given below also require the utilities in scripts numeric and trig. Load these as:
In [ ]:
load 'numeric trig'
The form is:
```opt plot data```
The right argument is the data to be plotted. The optional left argument specifies various plot options.
In general, 2D plots require x and y values given as a 2-element boxed list, and 3D plots require x, y and z values as a 3-element boxed list.
However, if the right argument is open, it is treated as y values (2D plots) or z values (3D plots) . It should be a matrix of data. A vector is treated as a 1-row matrix. For 2D plots, each row of the matrix is treated as a separate data item.
In [ ]:
plot 1 2 3 5
The following also plots a list of data, the sin of y where y ranges from 0 to 10 in 100 steps. The data is treated as y values, and the x values again default to i.#y
This time, the default x values are inappropriate - they are shown as in the range 0 to 100, but are actually in the range 0 to 10:
In [ ]:
plot sin steps 0 10 100
In [ ]:
x=: steps 0 10 100
In [ ]:
plot x;sin x
In [ ]:
plot (];sin) steps 0 10 100
In [ ]:
plot (sin;sin*cos) steps 0 10 100
In [ ]:
plot (sin;]) steps 0 10 100
In [ ]:
plot |. (];sin) steps 0 10 100
In [ ]:
'axes 1 1;labels 0' plot (sin;sin*cos) steps 0 10 100
In [ ]:
plot sin */~ steps 0 3 50
In [ ]:
'surface' plot sin */~ steps 0 3 50
In [ ]:
Z=: sin */~ steps 0 3 50
In [ ]:
'surface;viewsize 1 1 0.2;viewpoint 1 0 0.7' plot Z
In [ ]:
X=: Y=: steps _3 3 70
In [ ]:
Z=: (cos % 3&+) X (+/&:*:) Y
In [ ]:
'boxed 0' plot X;Y;Z
In [ ]:
'boxed 0;viewsize 1 1 0.05' plot X;Y;Z
In [ ]:
'sbar' plot >:?.>:i.3 5
In [ ]:
'fbar;title My Plot' plot >:?>:i.3 5
In [ ]:
pd 'reset' NB. reset plot
In [ ]:
pd 'type line' NB. set line type
In [ ]:
pd *: i.10 NB. set plot data
In [ ]:
pd 'show' NB. show it
In [ ]: