Skip to content

Instantly share code, notes, and snippets.

@ikashnitsky
Last active January 24, 2018 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ikashnitsky/2f6e29acbb9cbeb1694630c5932b8ad5 to your computer and use it in GitHub Desktop.
Save ikashnitsky/2f6e29acbb9cbeb1694630c5932b8ad5 to your computer and use it in GitHub Desktop.
Global convergence in male life expectancy at birth since 1950
################################################################################
#
# ikashnitsky.github.io 2017-07-17
# Trying ggjoy.
# The world convergence in male life expectancy at birth since 1950
# Ilya Kashnitsky, ilya.kashnitsky@gmail.com
#
################################################################################
library(tidyverse)
library(forcats)
library(wpp2015)
library(ggjoy)
library(viridis)
library(extrafont)
data(UNlocations)
countries <- UNlocations %>%
filter(location_type == 4) %>%
transmute(name = name %>% paste()) %>%
as_vector()
data(e0M)
e0M %>%
filter(country %in% countries) %>%
select(-last.observed) %>%
gather(period, value, 3:15) %>%
ggplot(aes(x = value, y = period %>% fct_rev()))+
geom_joy(aes(fill = period))+
scale_fill_viridis(discrete = T, option = "B", direction = -1,
begin = .1, end = .9)+
labs(x = "Male life expectancy at birth",
y = "Period",
title = "The world convergence in male life expectancy at birth since 1950",
subtitle = "Data: UNPD World Population Prospects 2015 Revision",
caption = "ikashnitsky.github.io")+
theme_minimal(base_family = "Roboto Condensed", base_size = 15)+
theme(legend.position = "none")
@PCK1992
Copy link

PCK1992 commented Jul 19, 2017

emilelatour that worked for me, too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment