Skip to content

Instantly share code, notes, and snippets.

@mschnetzer
Last active December 3, 2018 17:18
Show Gist options
  • Save mschnetzer/5ded9ca32ab537daf4182731c6cb9c61 to your computer and use it in GitHub Desktop.
Save mschnetzer/5ded9ca32ab537daf4182731c6cb9c61 to your computer and use it in GitHub Desktop.
Arbeitslosenrate für Österreich, 1955-2018 (https://twitter.com/matschnetzer/status/1069478841402290176)
library(tidyverse)
library(rdbnomics)
library(scales)
library(ggrepel)
library(msthemes)
unemp <- rdb(ids='OECD/MEI/AUT.LMUNRRTT.STSA.Q')
unemp$draw <- 1
unemp <- unemp %>% mutate(label = case_when(
value == max(value) ~ 1,
value == min(value) ~ 1,
TRUE ~0))
tempalette <- c("#b01111","#db7371","#c6dbee","#91c6e6","#3e9cd3")
unemp %>% ggplot(aes(x=period,y=draw,fill=value)) +
geom_bar(stat="identity",width=100) +
scale_fill_gradientn(colours=rev(tempalette),limits=c(1.4,9.2)) +
theme_ms() + theme(axis.title.y=element_blank(),axis.text.y=element_blank(),legend.position="none",panel.grid.major.y = element_blank(),plot.margin = unit(c(0.2,0.5,0.2,0.5), "cm")) +
scale_x_date(breaks = date_breaks("10 years"), labels = date_format("%Y"),limits = as.Date(c('1955-01-01','2018-07-01')), expand = c(0,0)) +
labs(x="",y="",title="Arbeitslosigkeit in Österreich",subtitle="Arbeitslosenrate nach nationaler Definition, 1955Q1-2018Q3",caption="Daten: OECD. Grafik: @matschnetzer") +
geom_label_repel(data=subset(unemp, label==1), aes(y=0.5,label=paste0(original_period,": ",round(value,1),"%")), nudge_y = c(-0.2,0.2), nudge_x = c(2000,-2000), fill="white", arrow = arrow(length = unit(0.02, "npc"), type = "open", ends = "last"), size = 3) +
ggsave("unempstripes.png", dpi = 300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment