Search Locate Previous Next Contents

Drawing a Population Pyramid

The population pyramid is one of the commonest demographic charts, and can be programmed in Rain with two back-to-back horizontal barcharts. The final effect looks like:


This was drawn by the function Population in the RainPro workspace:

 R„Population;MAT;bands
© Illustrate population pyramid (back-to-back horizontal bars)
 MAT„8 2½21 20,19 19,15 16,14 15,13 14,11 13,9 12,7 10
 bands„'0-9' '10-19' '20-29' '30-39' '40-49' '50-59' '60-69' '70+'
 ch.Set('STYLE' 'BOXED,hbar,cbar,relative,redraw')('xrange' ¯25 25)
© Make a fat central pillar with a datum line!
 ch.Set('Ystyle' 'atend')('datum' 'solid,ne,broad')
 ch.Set('Vmar' 48 48)('gap' 0.2)('Xdatum' 0)
 ch.Set('HEAD' 'Population of Ruritania')('Ycap' 'Age band')('Xcap' 'Millions')
 ch.Set('ylab'bands)('Key' 'Male' 'Female')
© Set ŒFMT string for labels (kill -ve signs) - new facility at Jan 1998
 ch.Set('qfmt' 'MI6')
© Test this with inside labels too!
 ch.Set('values'bands)('style' 'values') © ('vstyle' 'inside')
 ch.Bar MAT[;1]ׯ1  © Go left young man!
 ch.Bar MAT[;2]     © Females to the right!
 PG„ch.Close
 R„'View PG © to see it'

Some things to note are:

These are all useful tricks to note, and are very typical of the coding style you need when you are developing relatively complex charts which combine several data-sets on the same axes.



Continue to: Managing Multiple Plots
© Copyright Causeway Graphical Systems Ltd 2003