get_legend: Extract Legends from a ggplot object

Description Usage Arguments Value Examples

View source: R/get_legend.R

Description

Extract the legend labels from a ggplot object.

Usage

1

Arguments

p

an object of class ggplot.

Value

an object of class gtable.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create a scatter plot
p <- ggscatter(iris, x = "Sepal.Length", y = "Sepal.Width",
        color = "Species", palette = "jco",
        ggtheme = theme_minimal())
p

# Extract the legend. Returns a gtable
leg <- get_legend(p)

# Convert to a ggplot and print
as_ggplot(leg)

YTLogos/ggpubr documentation built on May 3, 2019, 9:04 p.m.