g_legend: Extract a legend from ggplot

Description Usage Arguments Value Examples

View source: R/plotHelp.R

Description

Grab the legend from a ggplot object and use it for saving in its own file

Usage

1
g_legend(a.gplot)

Arguments

a.gplot

ggplot plot object with a color / fill legend

Value

A new ggplot object with only the legend

Examples

1
2
3
df <- data.frame(x = rnorm(1000), y = 0)
p1 <- ggplot(shuf(df), aes(x=x, y=y, colour=x)) + geom_point()
legendP <- g_legend(p1)

caleblareau/BuenColors documentation built on March 7, 2020, 3:34 p.m.