Category Archives: data visualization

Comparing the composition of population aged 80 years old and above

Data Input:

USA: 1st April 2010 Census

Italy: EUROSTAT population 1st January 2000-2017

China: 1st November 2010 Census

Personal elaboration of data: 2020 mid year population by sex and age and age-group

Comparing the proportion of population aged 80 and above in different countries.

  • USA

Screenshot 2020-03-23 10.57.20

  • China


  • USA, Italy, and China using Italy’s color palette range:

Regional age-sex composition in Germany by NUTS2 60 to 80+ years old


Data source: EUROSTAT, personal elaboration of data. Population by age and sex at 1st of July 2020.

GGplot of COVID-19 cases using Italian Health Ministry data

Screenshot 2020-03-22 at 17.14.33.png

Data link

Order labels (this is according to the total number of cases on the 20th of March:
mydt$ord <- factor(mydt$denominazione_provincia, levels=c( 'Bergamo', 'Brescia', 'Milano', 'Cremona', 'Lodi', 'Pavia', 'Mantova', 'Monza e della Brianza', 'Piacenza', 'Sondrio', 'Varese', 'Lecco', 'In fase di definizione/aggiornamento'))

Graph code:
ggplot(mydt%>% filter(codice_regione =='03'))+ #select one region, in this case Lombardia
geom_bar(stat='identity', aes(x=data, fill=ord, y=totale_casi))+
theme(legend.title = element_blank())+
scale_fill_manual(values=c('#a6cee3', '#1f78b4','#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928', '##000000', '#f0f0f0'), labels=c( 'Bergamo', 'Brescia', 'Milano', 'Cremona', 'Lodi', 'Pavia', 'Mantova', 'Monza', 'Piacenza', 'Sondrio', 'Varese', 'Lecco', ''))+
labs(x = '' , y = 'Total cases')+
theme(legend.title = element_blank())

Composite plots: grid.arrange

I really like composite plots, where there’s a top part that describes a phenomenon and a bottom part with a synthetic time view of the overall process.
I’ve recently discovered this beautiful representation of educational differentials by gender, by Sara Lopus and Margaret Frye, and the beauty of this dataviz is that it tells a story on its own. (Click on the link for the publication)

I have used a random generated data to reproduce the graph in ggplot and used grid.arrange from gridExtra package to bind grobs, the top and bottom components.

grid.arrange(top, bottom, heights=c(10,5), widths=c(20), padding=0)

I have saved the map as a .png file png package and used rasterGrob from package grid to create a raster image graphical object.

Screen Shot 2018-08-30 at 11.26.50