R/get_legend.R

Defines functions get_legend

# function to extract legend

get_legend <- function(
    plot
  ){

  tmp <- ggplot_gtable(ggplot_build(plot))
  leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
  legend <- tmp$grobs[[leg]]

  return(legend)

}
MargotBr/SeqAgSorting documentation built on Dec. 3, 2023, 11:21 p.m.