Last active
July 9, 2022 06:45
-
-
Save charliejhadley/7c46ccfff81c69b243b0a97a79fe3659 to your computer and use it in GitHub Desktop.
synthetic-aesthetic.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(rnaturalearthdata) | |
library(sf) | |
country_sf <- countries110 %>% | |
st_as_sf() | |
ggplot() + | |
geom_sf(data = country_sf, | |
aes(fill = lastcensus, | |
shape = "No data\navailable")) + | |
scale_fill_viridis_c() | |
# Nicer version of chart | |
ggplot() + | |
geom_sf(data = country_sf, | |
aes(fill = lastcensus, | |
shape = "No data\navailable"), | |
colour = "white", | |
size = 0.2) + | |
scale_fill_viridis_c(na.value = "pink") + | |
guides(shape = guide_legend(override.aes = list(fill = "pink"), | |
order = 2, | |
title = NULL), | |
fill = guide_colorbar(order = 1)) + | |
theme_void() + | |
theme(legend.margin = margin(r = 5)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment