get_legend2 {pcutils} | R Documentation |
Get a legend from a ggplot object
Description
Get a legend from a ggplot object
Usage
get_legend2(plot, legend = NULL)
Arguments
plot |
a ggplot object |
legend |
NULL, or position ("top") |
Value
a grob object, or NULL if no legend found
Examples
library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg, color = mpg)) +
geom_point()
legend <- get_legend2(p)
plot(legend)
[Package pcutils version 0.2.8 Index]