Age pyramid looks like this: alt text
I would like to make something similar, namely a 2 barplots (not histograms) with same categories, rotated vertically and extending to both sides as in pyramid.
Is it a simple way to do this in R?
It would be also nice to control the colour of each bar.


locked by whuber Jul 17 '16 at 19:59

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

Read more about locked posts here.


You can do this with the pyramid.plot() function from the plotrix package. Here's an example:

  main="Australian population pyramid 2002",lxcol=mcol,rxcol=fcol,

Which ends up looking like this: alt text

  • $\begingroup$ Ok, indeed I rewrote it completely to have different scales on both sides, but it seems there is nothing in R that can do it natively. $\endgroup$ – user88 Sep 9 '10 at 13:24
  • $\begingroup$ I'm sure that you could do it with ggplot2, but it would require a little effort. $\endgroup$ – Shane Sep 9 '10 at 13:44
  • $\begingroup$ @mbq Also FYI there is a pyramid chart capabilities in the HH package. This question on the site gives examples for Likert type data, which I imagine can be hacked to produce similar bar charts. In ggplot2 one would need to display reflected counts, an easy way is to just have one bar be negative and the other be positive (not sure if ggplot2 supports mirrored dimensions like pyramid plots though). $\endgroup$ – Andy W Feb 3 '13 at 14:45