Lisp-Stat's plotting capability is excellent. One-dimensional
arrays of numbers can be plotted with the
plot-lines functions. If we try something like
> (plot-points beach_gravity) Error: too few arguments Happened in: #<Subr-PLOT-POINTS: #c01c8>we get an error message. So let's see what that's all about. Let's get some help
> (help (quote plot-points)) PLOT-POINTS [function-doc] Args: (x y &key (title "Scatter Plot") variable-labels point-labels symbol color) Opens a window with a scatter plot of X vs Y, where X and Y are compound number-data. VARIABLE-LABELS and POINT-LABELS, if supplied, should be lists of character strings. TITLE is the window title. The plot can be linked to other plots with the link-views command. Returns a plot object. NILEverything past the
&in the line beginning Args: represents an option, so let's postpone discussing these for a bit. Right away we see that the
plot-pointsfunction is expecting both an ordinate and an abscissa. So we can fake an abscissa just by defining a list of integers
> (plot-points (iseq (length beach_gravity)) beach_gravity) #<Object: 1412952, prototype = SCATTERPLOT-PROTO>or
> (plot-lines (iseq (length beach_gravity)) beach_gravity) #<Object: 1438744, prototype = SCATTERPLOT-PROTO>The latter result is shown in Figure 1.1. The function
iseqsimply creates an integer sequence of the given length. The odd looking line beginning
#<Object:can be used later to identify plots. For now we're not going to worry about this; henceforth these messages will be suppressed.
Figure: The function
plot-lines applied to the
beach gravity data.
In these last few examples we have used an array that we typed in by hand. More often we will read a file in from disk or create some array with one of Lisp-Stat's functions. For example, let's create three arrays according to three different pseudo-random number generators.
> (def uniform (uniform-rand 100)) UNIFORM > (def gaussian (normal-rand 100)) GAUSSIAN > (def chisquared (chisq-rand 100 5)) CHISQUARED
Here we have defined 3 arrays length 100 containing pseudo-random samples drawn from, respectively, the uniform, normal and distributions. The statistical interpretations are not important now, here we're just generating some numbers to play with. Now we can plot them. For example,
> (scatterplot-matrix (list uniform gaussian chisquared) :variable-labels (list "Uniform" "Gaussian" "Chi-squared") )generates the scatter plot matrix shown in Figure 1.2. While
> (spin-plot (list uniform gaussian chisquared))generates a spin plot that can be rotated interactively-just click on one of the 6 buttons at the bottom of the display (2 each for pitch, roll and yaw). This is shown in Figure 1.3.
Figure 1.2: A scatter plot matrix.
Figure 1.3: A spinning plot.