Skip to content

Instantly share code, notes, and snippets.

@karawoo
Created August 6, 2019 00:33
Show Gist options
  • Save karawoo/ddef4ca9a4294322fa0ee7fa8b3b5526 to your computer and use it in GitHub Desktop.
Save karawoo/ddef4ca9a4294322fa0ee7fa8b3b5526 to your computer and use it in GitHub Desktop.
library("cholera")
library("tidyverse")
library("magick")
library("grid")
library("egg")
# Get image
bree <- image_read("https://pbs.twimg.com/media/EBPHuylUIAAziJt?format=jpg")
# Add x/y coordinates of Broad St. pump and convert format
image_data <- filter(pumps.vestry, street == "Broad Street") %>%
select(x, y) %>%
mutate(image = list(rasterGrob(bree, width = unit(0.05, "npc"))))
# Plot
ggplot(mapping = aes(x = x, y = y)) +
geom_path(data = roads, aes(group = street), color = "gray") +
geom_point(data = fatalities) +
geom_point(data = pumps.vestry, color = "blue", stroke = 0.75) +
geom_custom(data = image_data, aes(data = image), grob_fun = identity) +
ggsave("geom_bree.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment