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 ============= 
 chNew 0 154 205 308 
 chSet('HMAR' 24)('HEAD' 'Here is a Simple Grouped Barchart;with a Displaced X-Axis') 
 chSet('XLAB' 'York,Hfx,Nch,Ltr,Gls')('Hf' '8')('Yint' 20) 
 chBar MAT 
© ============== STACKED BARCHART ============= 
 chNew 0 0 205 154 
 chSet('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)
 chSet('XLAB' 'York,Halifax,Norwich,Leicester,Glasgow')
 chSet('XS' 'Angled')('XA' 25)
 chBar MAT 
© ============== FLOATING BARCHART ============= 
 chNew 205 154 411 308 
 chSet('STYLE' 'RELATIVE,FBAR,VALUES')('HMAR' 24)('HEAD' 'Here is a Floating Barchart;with Value Labels on the Bars') 
 chSet('Values' 'York,Hfx,Nch,Ltr,Gls') 
 chSet('YSTYLE' 'GRID,MTICK')('Hfont' '8') 
 chBar MAT 
© ==== OVERLAPPED BARCHART WITH DATUM ==== 
 chNew 205 0 411 154 
 chSet('STYLE' 'RELATIVE')('HMAR' 24)('HEAD' 'A Relative Barchart with overlapped bars;and Displaced Baseline') 
 chSet('XLAB' 'York,Hfx,Nch,Ltr,Gls')('GAP' ¯0.5) 
 chSet('BASELINE' 20)('Hfont' '8') 
 chBar MAT 
 PG„chClose 
 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 ...

 chNew 0 0 .5 .5×4½432 324      © lower left 
 chNew .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