Description Usage Arguments Value Examples
Extract the legend labels from a ggplot object.
1 | get_legend(p)
|
p |
an object of class ggplot. |
an object of class gtable.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.