Skip to content

Instantly share code, notes, and snippets.

@necronet
Created June 4, 2020 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save necronet/b65e2e819ec1e9344a501d5681413d95 to your computer and use it in GitHub Desktop.
Save necronet/b65e2e819ec1e9344a501d5681413d95 to your computer and use it in GitHub Desktop.
On Adding a custom gradient w/ background layer to ggplot
g <- rasterGrob(greens, width = unit(1, "npc"), height = unit(1, "npc"), interpolate = TRUE)
test <- ggplot(mtcars, aes(x = mtcars$hp, y = mtcars$mpg)) +
theme(plot.background = element_blank(),
panel.background = element_blank()) +
annotation_custom(
grob = g, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf
) + geom_point()
plot_grid(test, labels = c('A'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment