Learn R Programming

ggplot2bdc (version 0.3.2)

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

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

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

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

Run the code above in your browser using DataLab