| Locate Previous Next | Contents |
Many statistical plots require being able to plot a series of points, either as points themselves indicated by markers, or connected with lines: you name it, you can do it, with Rain! The obvious candidates in this category are time-series, scatterplots, histograms and function plots. The workspace you are using has some utility functions added to help construct these plots but we need some simple examples first to get the feel of the way Rain works.
To start, we investigate the function ch.Plot at the same time we dig a little deeper into the structure of Adrians graphics. To begin our investigation, suppose we have a set of time-series values which we wish to plot. Rain defaults to time-series mode and so all that is required are the values of the time-series:
ts?10½10
ch.Plot ts
View PGch.Close
You can label the axes appropriately use ch.Set 'xcap' 'time' and ch.Set 'ycap' 'Time-series values', and of course you already know how to put a header on the graph! We have allocated the returning value of the function ch.Close to a variable PG so inspect it with the command )ed PG. The text in this variable contains PostScript code! This is cleverly interpreted by the function View so that we can see a screen representation.
What happens if we use another ch.Plot command?
ts?10½10
ch.Plot ts
ch.Plot ¼20
View PGch.Close
First, note that the second dataset is plotted (as a time-series) but with a change of marker and line-type. However the plotting range has been set by the first plot, and so not all points (1 to 20) are visible for multiple plots on one set of axes you need to control the range with a command such as ch.Set ('yrange' 0 20)('xrange' 1 20) note how two or more separate calls to the ch.Set function may be made at the same time.
If you wish to use only lines and not markers (or markers and not lines) then use ch.Set again:
ch.Set 'style' 'nolines,markers'
ch.Plot ts
ch.Set 'style' 'lines,nomarkers'
ch.Plot ¼20
View PGch.Close
Finally in this section, if you have (x,y) data (where there is no default set of x-values as for time-series) then you must declare the plot to be an xyplot
ch.Set 'style' 'xyplot,markers,nolines'
ch.Plot (?100½100)(?100½100)
View PGch.Close
Summary
You can overlay several plots on the same set of axes, but remember that the first plot you draw fixes the range for all of them!