Skip to content

Instantly share code, notes, and snippets.

@mschnetzer
Created December 22, 2022 19:37
Show Gist options
  • Save mschnetzer/a61c00907d229f465b52468c2d53c2df to your computer and use it in GitHub Desktop.
Save mschnetzer/a61c00907d229f465b52468c2d53c2df to your computer and use it in GitHub Desktop.
Wenn Österreich so verteilt wäre wie Vermögen (https://twitter.com/matschnetzer/status/1605844993683337216)
library(tidyverse)
library(msthemes)
library(sf)
library(showtext)
font_add_google("Roboto Condensed", "Roboto")
font_add_google("Playfair Display", "Playfair")
font_add_google("Roboto Mono", "Mono")
showtext_opts(dpi = 320)
showtext_auto()
geodat <- st_read("https://raw.githubusercontent.com/ginseng666/GeoJSON-TopoJSON-Austria/master/2017/simplified-99.5/gemeinden_995_geo.json",
quiet=TRUE, stringsAsFactors=FALSE) |>
mutate(
center = map(geometry, st_centroid),
centercoord = map(center, st_coordinates),
ccordx = map_dbl(centercoord, 1),
ccordy = map_dbl(centercoord, 2)
) |>
mutate(iso = as.numeric(iso))
geodat$area <- st_area(geodat)
total <- sum(geodat$area)
arbreaks <- total*c(0, 0.389, 0.657, 0.972, 1)
ardf <- geodat |> arrange(ccordx) |> mutate(csarea = cumsum(area)) |>
mutate(gruppe = cut(csarea, breaks=arbreaks))
## COLOR
ardf |> ggplot() +
geom_sf(aes(fill=gruppe), color="black", linewidth=0.06) +
geom_sf(fill="transparent", color="black", linewidth = 0.3,
data = . |> group_by(gruppe) |> summarise()) +
coord_sf(datum=NA) +
expand_limits(x=19) +
annotate("text",label="Dem Top 1% würden fast\n 40% der Fläche gehören", size=2.5, family="Roboto", hjust=0.5, x=11, y=48.3) +
annotate("text",label="Die reichsten 2-10% würden rund\n ein Viertel der Fläche besitzen", size=2.5, family="Roboto", hjust=0.5, x=13, y=49.2) +
annotate("text",label="Die nächsten 40% hätten\n etwa ein Drittel der Fläche", size=2.5, family="Roboto", hjust=0.5, x=16, y=46.2) +
annotate("text",label="Die ärmere Hälfte\n der Bevölkerung\n teilt sich 2,8% der Fläche", size=2.5, family="Roboto", hjust=0.5, x=17.6, y=47) +
geom_curve(aes(x=11.5,xend=12, y=48.1,yend=47.7), curvature = -0.1, ncp=8, linewidth=0.1, arrow=arrow(length=unit(0.01, "npc"), type="closed")) +
geom_curve(aes(x=14,xend=14.5, y=49,yend=48.7), curvature = -0.1, ncp=8, linewidth=0.1, arrow=arrow(length=unit(0.01, "npc"), type="closed")) +
geom_curve(aes(x=15.5,xend=15.7, y=46.4,yend=46.65), curvature = 0.1, ncp=8, linewidth=0.1, arrow=arrow(length=unit(0.01, "npc"), type="closed")) +
geom_curve(aes(x=17.5,xend=17.2, y=47.3,yend=47.9), curvature = 0.1, ncp=8, linewidth=0.1, arrow=arrow(length=unit(0.01, "npc"), type="closed")) +
scale_fill_manual(values = MetBrewer::met.brewer("Egypt", direction = -1),
labels = c("Top 1%","Reichste 2-10%","Nächste 40%","Ärmere 50%")) +
theme_ms(alttf = T) +
labs(title="Wenn Österreich so verteilt wäre wie Vermögen...",
caption = "Quelle: HFCS 2017; ICAE 2020. Grafik: @matschnetzer",
x="",y="") +
theme(legend.title = element_blank(),
legend.position = "top",
legend.key.size = unit(0.3 , "cm"),
plot.title = element_text(margin = margin(b=0.5,unit="cm"), family = "Playfair", size = 14),
plot.caption = element_text(family = "Roboto", size = 5),
legend.text = element_text(family = "Roboto", size = 8))
ggsave("areadist_2017.png", dpi=320, unit="in", width = 6.5, height = 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment