Skip to content

Instantly share code, notes, and snippets.

@crsh
Created April 30, 2017 13:52
Show Gist options
  • Save crsh/be88be19233f1df4542aca900501f0fb to your computer and use it in GitHub Desktop.
Save crsh/be88be19233f1df4542aca900501f0fb to your computer and use it in GitHub Desktop.
Plot only legend of a ggplot
# Stolen from http://stackoverflow.com/a/12041779/914024
gglegend <- function(x){
tmp <- ggplot_gtable(ggplot_build(x))
leg <- which(sapply(tmp$grobs, function(y) y$name) == "guide-box")
tmp$grobs[[leg]]
}
@chansigit
Copy link

stolen haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment