7.1 Generating 3D data

By default, the objects that plotdata manipulates are vectors, i.e. inherently one-dimensional things. However, one can create a one-dimensional equivalent of a two-dimensional object by ``unravelling'' the m x n matrix like this:

The last line can then be thought of as a mapping , where

This presupposes that we know on a regular array of data points . Here's one quick way of creating such a mapping:

PLOTDATA: generate j 0,,99 100
PLOTDATA: x=int(j/10)*10
PLOTDATA: y=j-x
PLOTDATA: z=(x-50)**2*exp(-0.1*(y-5)**2)
PLOTDATA: list x,y,z
PLOTDATA: density/boxes x,y,z

We generated three vectors of length 100, and then interpreted them as a three-dimensional object. The /boxes switch shows off one more way of rendering such a ``surface''.

To do the surface justice, however, it is best to perform the reverse: take a set of vector (1D) data and then create a regularly-spaced grid matrix out of it:

PLOTDATA: grid m x,y,z
PLOTDATA: surface m 0 0 25 -30

Note that we have used our regular arrays x, y, and z to generate a matrix m, but in general grid command will interpolate data as needed, so the input data representing a surface need not be known at a regularly-spaced grid of points . For our arrays we could have used the option grid/nointerpolate since the data is already regularly spaced.


Up: 7. Surfaces, contours, and other 3D plots Next: 8. Real programming: if's and do's Previous: 7. Surfaces, contours, and other 3D plots