gg_remove_legend: Remove a legend or parts of a legend from a plot

Description Usage Arguments Value Examples

Description

gg_remove_legend Removes a plot's legend or some of its components

gg_remove_legend_title Removes legend's title

gg_remove_legend_key Removes legend's key

gg_remove_legend_text Removes legend's item labels

gg_remove_legend_background Removes legend's background

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
gg_remove_legend(plot = last_plot(), title = TRUE, key = TRUE,
  text = TRUE, background = TRUE)

gg_remove_legend_title(plot = last_plot())

gg_remove_legend_key(plot = last_plot())

gg_remove_legend_text(plot = last_plot())

gg_remove_legend_background(plot = last_plot())

Arguments

plot

A ggplot2 plot object. By default, the last plot displayed is used.

title

Whether or not to remove the legend's title (default: TRUE)

key

Whether or not to remove the legend's key (default: TRUE)

text

Whether or not to remove the legend's key text (default: TRUE)

background

Whether or not to remove the legend's background (default: TRUE)

Value

A modified ggplot2 plot

Examples

1
2
3
p <- ggplot(mtcars, aes(x = cyl, y = mpg)) +
    geom_point(shape = 1)
gg_remove_legend(plot = p)

briandconnelly/ggplot2bdc documentation built on May 13, 2019, 5:13 a.m.