R/extract_legend.R

Defines functions extract_legend

Documented in extract_legend

##' extract the legend of a \code{ggplot} object
##'
##' @param plot a \code{ggplot} object
##' @export
##'
extract_legend <- function(plot)
{
  legend = ggplotGrob(plot)$grobs

  legend[[which(sapply(legend,function(x)x$name) == "guide-box")]]

}
welch16/rwlib documentation built on Jan. 13, 2020, 1:27 p.m.