GraPL > GraPL Desktop > Tutorials > Multiples > Duplicate axes
 

Multiple Series and Duplicate Axes

One of the unusual features of GraPL is that there really is no limit on how many data-series you can plot against the same set of axes. The only rule is that the first one you plot will set the axes up for all the rest. You can mix and match any compatible charts (you can draw a piechart on top of a barchart, but it makes little sense to do so) which makes it really easy to draw error-bar charts, overlay line-plots on barcharts, fit mesh responses through 3D scatter plots and so on.

Plotting several series on one set of axes

A simple and very common use of this capability is plotting error-bars through a scatter-plot of some experimental results. GraPL is shipped with a basic ErrorBar template which is really all you need if the error is constant (say +/-5 for each measurement); however a more interesting case is where you have computed the error for each point, and have the error value in a separate column in the data sheet.

OK, I just made these numbers up, but you can see the idea – the error gets bigger as the experiment gets hotter. To plot the data with the errorbars is now quite easy:

... but notice that I intentionally plotted the errorbars first – remember that GraPL sets up the axes to suit the first series you plot, and that the extreme y-values of the bars will definitely exceed the extreme values in the data. In general it makes sense always to plot the widest-ranging dataset first, although you can always set the axis ranges explicitly. In fact here I have set the x-ticks to (5,4) which has had the effect of slightly extending the computed x-range to include 10 as the first tickmark.

The Min-Max plot can show a simple unadorned line, a line with conventional errorbar ‘T-pieces’ at each end, or a line with arrowheads at each end. This last is suitable if you really want to emphasise the range of the data, but if you use arrowheads in this example you will probably want to make them a little smaller than the default size – try switching the Min-max style to ‘Arrows’ and adding an extra ‘Arrow style’ property to see the effect.

The chart easily extends to showing a possible measurement error in the temperature – say we can only read our thermometer to within one degree, but this time the error is constant across the experiment:

The only thing that is new here is the addition of the ‘Horizontal’ style setting to the Min-Max chart – this effectively swaps the axes, so here we plot the range in Temperature versus the Yield. Again, I have used conventional errorbars here.

Overlaying bars and lines

Often, you want to show measured values as a barchart, and plot a theoretical curve over the top as a line – this next example is very typical of an experiment where we counted some values, then worked out a theoretical fit which we should overlay as a smooth curve.

The experiment involved a routine test on an automatic checkweigher which was supposed to reject any pack below 224 grams. What you need to do is to make up a range of test packs (from 220gm to 232gm in this case) and send them over the weigher in random order, lots of times. In this case we did 50 runs, and you can see that it successfully rejected all 50 packs at the lowest weight, but that 3 packs at 221gm sneaked across. Similarly, it accepted all the 232gm packs but on one occasion it threw off a pack at 230gm! This data fits very well (both theoretically and practically) to a curve called the Logistic, so what I have done here is plotted the raw data as a barchart, with my best estimate of the ‘real’ behaviour superimposed as a line:

When I added the Linechart element, it brought along rather more properties than I needed – in particular you can delete the spare ‘Axes’ settings as the barchart has already set all these up and we can’t change them here. Alternatively, you can hold Alt as you drag to get the chart on its own, and add the extra properties as you need them. Now we can make some sensible ‘business’ decisions – just where would you set the cutoff weight if you wanted to be ‘reasonably sure’ that you didn’t ship any packs below the declared weight of 224gm?

Using a secondary Y-axis

The above style works very well if you are plotting two datasets which have the same vertical span – but what if you want to compare two completely different series, for example the sales of hamburger buns against daily mean temperature? It is a very reasonable guess that in hot weather people have barbecues, but just how real is the effect?

Here is a comparison of the daily temperatures (read from a thermometer in my back garden) and the weekly sales of buns by a local bakery. Both axes have been allowed to auto-range, and I have allowed GraPL to take most of the normal defaults. The things you need to do to add a secondary axis are:

  • drag over a ‘Y-sec’ chart element and drop it on the chart specification after the first chart. It comes along with some very basic axis properties (such as the Y-caption) which let you customise the second axis
  • modify the chart margins to make room for the axis labels and caption at the right – here I have made the right margin 36 points to match the left
  • drag on your second chart, in this case another linegraph, remembering to hold Alt so you just get the bare chart definition added to the spec.

Obviously, you can plot several series (possibly using different chart types) on the primary axis, then switch to a secondary axis and plot as many more as you like. The only restriction you might notice is that the (x,y) readout in the statusbar always shows where the mouse is against the primary axes.


Continue to: Multiple Charts and Trellis Plots


© Copyright Causeway Graphical Systems Ltd 2000-2007
Telephone: +44 (0)1439 788413