A function to call ggplot population pyramids in one line

What does it do?

If you have a dataset with several (or all!) countries/ regions/ ages/ etc and you want a short call function to plot without having to modify the ggplot2 code every time (e.g. a certain country for a certain year), here’s a solution.

Just save the r script with the function for the plot and call it when you want to use it:


The next step will be to use facet_wrap to select sub-national administrative units at once to be compared against the national plots.
Data can be found for Iraq at national level on my github page.

Below is the population pyramid for Iraq in year 2000


Author: acarioli

is a researcher at the Geography and Environment department of the University of Southampton, WorldPop project team. She is also affiliated researcher at CED, UAB and Dondena Centre. Her interests include spatial econometrics and modeling, bayesian methods, machine learning processes, forecasting, micro-data simulation, and data visualization. Demo-traveler, Mac enthusiast, R zealot and Rladies member.