Search Locate Previous Next | Contents |

3D charts are very easy to do badly, and quite hard to do well! There are also many examples of 3D representations of essentially 2D data which do nothing other than hide the values and make it impossible to compare series accurately. Hence the functions in this section of Rain come with a health warning – use them to investigate genuinely 3D data by all means, but beware of towers and such unless your primary object is simply to make the output look pretty!

**Tower Charts**

The functions below are taken in order of ease of use, leaving until last `ch.Cloud`

which is the real workhorse for genuine 3D charting. Towers are by far the simplest, as there are almost no settings to change and the data is a simple rectangular array. For example:

ch.Set'Head' 'Standardised Test Scores' ch.Set('Ycap' 'Category')('Xcap' 'Pupil')('zcap' 'Score') ch.Set('zs' 'atend') ch.Set('GGap' 2)('cfont' 'ti,cyan,15') ch.Set'yl' 'Maths' 'English' 'Geography' 'Art' ch.Set'xl' 'Ian' 'John' 'Sean' 'Jon' 'Fred' 'Bert' 'Ally' 'Sue' 'Joan' ch.Set'Grid,walls' © Best to get the bigger numbers to the back! ch.Tower´+\+™?9 4½20 PG„ch.Close

All the normal axis settings (ranges, tick spacing, captions) apply to the Zaxis as you would expect. The gap between towers has been set here as twice the tower base using the Group Gap property. Note that you can only set gridlines globally here – the ‘grid’ axis style is ignored. By default, the data is arranged with the rows parallel to the X-axis and the columns retreating back into the page along the Y-axis. This means that a tower chart behaves exactly like a grouped barchart with each group of bars spread back into the Y-plane. You can set the viewpoint and perspective distortion if required, but the default settings work quite well for the majority of simple 3D charts.

**Response Surfaces**

As with the tower chart, this can take a simple rectangular array of data (zvalues) and draw it as a mesh surface above the XY plane. This looks best either with markers turned off completely, or with the small dots/spheres which are found as markers 9 – 15. Here is a simple array drawn as a mesh with marker 14 at the intersections:

This was drawn with the same function as the Tower chart, simply substituting `ch.Resp`

for `ch.Tower`

at the end and adding the marker setting. If you need to set the X and Y values explicitly, you can pass a 3element array giving a vector of X-values, a vector of Y-values and a matching rectangular array as before.

ch.Set('style' 'grid')('marker' 14) © Best to get the bigger numbers to the back! © Distort axes to show non-linear mesh. ch.Resp(2*þ¼12)(0.5*þ¼9)(´12 9½¼108) PG„ch.Close

This could be used to draw a fitted plane through a scatter of points in XYZ space, or just to illustrate the shape of an interesting maths function. The final possibility is to tile the surface, which has the effect of hiding the folded parts and giving a more solid feel to the remainder.

ch.Set('style' 'walls,tiled')('Pattern' 2)('ls' 'flat') ch.Resp 2±0.2×(0,¼24)°.+0,¼24 PG„ch.Close

**Cloud Charts (XYZ Scatter Plots)**

The `ch.Cloud`

function will plot arbitrary values in XYZ space, with the option of lines, markers, risers from the XY plane and filled surfaces to the XY plane or a given baseline. As is usual for charts plotted by Rain, the first call sets up the axes (auto-ranging if required) and subsequent calls plot further data against the same axes. This allows you a great deal of flexibility in drawing 3D data – see the example function `Profile`

(in the Rain workspace) for some ideas.

In this case, you always give a 3-column matrix of XYZ triples, which will be plotted from the far back corner forward to ensure nearer points are drawn on top. A simple scatter-plot (`Cloud1`

in the RainPro workspace) is ideal for spotting clusters and anomalies in the data:

ch.Set('style' 'grid,norisers,nolines')('Marker' 14) ch.Set('Xcap' 'Pressure in Bars')('Ycap' 'Temperature')('Zcap' 'Yield') ch.Cloud DATA

You can experiment with other options, such as ‘risers’ to see how they work with your data.

A second use of this function is to draw several sets of data (for example parallel time-series) as a set of independent plots against the same axes. Here is a simple example which loops across the columns of a set of invented timeseries:

mat„+³†0.8 ExpSmooth¨‡³?60 5½12 ch.Set('HEAD' 'A Set of Shaded Planes') ch.Set('XT' 5)('YT' 1)('YR' 0 5)('ZS' 'forcezero') ch.Set'surface,grid,nomark' © Tallest first sets the Z-range! :For plane :In ²¼¯1†½mat ch.Cloud(¯1+¼1†½mat),plane,mat[;,plane] :End

Obviously you could equally well loop in the other dimension to plot surfaces parallel to the Y-axis. With careful choice of colours, patterns and markers it should be possible to construct most reasonable 3D charts with this function alone. You can then experiment with combinations, for example using a mesh surface to plot the regression result through the cloud of data points.

Continue to: Illustrating a Maths Function

© Copyright Causeway Graphical Systems Ltd 2003