Search Locate Previous Next Contents

Four Barcharts on One Page

Anyone can plot graphs! One of the great strengths of Rain is its ability to combine several plots on the same finished graphs – see SmallMultiple for this idea taken to its logical conclusion.

This example is in the Rain workspace as Sambars – please take the code apart to see how it was done in detail.

 R„Sambars;MAT 
© Build set of 4 sample barcharts from MAT 
 MAT„?5 3½36 
© ============== GROUPED BARCHART ============= 
 ch.New 0 154 205 308 
 ch.Set('HMAR' 24)('HEAD' 'Here is a Simple Grouped Barchart;with a Displaced X-Axis') 
 ch.Set('XLAB' 'York,Hfx,Nch,Ltr,Gls')('Hf' '8')('Yint' 20) 
 ch.Bar MAT 
© ============== STACKED BARCHART ============= 
 ch.New 0 0 205 154 
 ch.Set('STYLE' 'RELATIVE,CBAR,VALUES')('HMAR' 24)('HEAD' 'This is a Simple Stacked Barchart')('Hf' '8') 
© Angled X-labels at 25deg allow longer names (version 4.4)
 ch.Set('XLAB' 'York,Halifax,Norwich,Leicester,Glasgow')
 ch.Set('XS' 'Angled')('XA' 25)
 ch.Bar MAT 
© ============== FLOATING BARCHART ============= 
 ch.New 205 154 411 308 
 ch.Set('STYLE' 'RELATIVE,FBAR,VALUES')('HMAR' 24)('HEAD' 'Here is a Floating Barchart;with Value Labels on the Bars') 
 ch.Set('Values' 'York,Hfx,Nch,Ltr,Gls') 
 ch.Set('YSTYLE' 'GRID,MTICK')('Hfont' '8') 
 ch.Bar MAT 
© ==== OVERLAPPED BARCHART WITH DATUM ==== 
 ch.New 205 0 411 154 
 ch.Set('STYLE' 'RELATIVE')('HMAR' 24)('HEAD' 'A Relative Barchart with overlapped bars;and Displaced Baseline') 
 ch.Set('XLAB' 'York,Hfx,Nch,Ltr,Gls')('GAP' ¯0.5) 
 ch.Set('BASELINE' 20)('Hfont' '8') 
 ch.Bar MAT 
 PG„ch.Close 
 R„'View PG © to see it'

Some things which you might like to note are:

All measurements are in points (one point = 1/72 inch), and the default page size is 432 wide by 324 high. Astute (non-metric) readers will notice that this translates to 6” by 4.5”, and gives a proportion of exactly 4 wide by 3 high. If you simply want to divide the plotting space into for equal sections, you can ask APL to do the sums ...

 ch.New 0 0 .5 .5×4½432 324      © lower left 
 ch.New .5 .5 1 1×4½432 324      © top right

... and so on.



Continue to: Making a Trellis of Small Plots
© Copyright Causeway Graphical Systems Ltd 2003