Skip to content

Instantly share code, notes, and snippets.

@charliejhadley
Last active July 9, 2022 06:45
Show Gist options
  • Save charliejhadley/7c46ccfff81c69b243b0a97a79fe3659 to your computer and use it in GitHub Desktop.
Save charliejhadley/7c46ccfff81c69b243b0a97a79fe3659 to your computer and use it in GitHub Desktop.
synthetic-aesthetic.R
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