Learn R Programming

ggplot2bdc (version 0.3.2)

gg_remove_titles: Remove titles from a plot

Description

gg_remove_titles removes title elements such as the main title, subtitle, caption, or axis titles. By default, all are removed. gg_remove_title Removes the plot's main title gg_remove_subtitle Removes the plot's subtitle gg_remove_caption Removes the plot caption gg_remove_title.x Removes the X-axis title gg_remove_title.y Removes the Y-axis title

Usage

gg_remove_titles(plot = last_plot(), title = TRUE, subtitle = TRUE,
  caption = TRUE, x = TRUE, y = TRUE)

gg_remove_title(plot = last_plot())

gg_remove_subtitle(plot = last_plot())

gg_remove_caption(plot = last_plot())

gg_remove_title.x(plot = last_plot())

gg_remove_title.y(plot = last_plot())

Arguments

plot
A ggplot2 plot object. By default, the last plot displayed is used.
title
Whether or not to remove the main title (default: TRUE)
subtitle
Whether or not to remove the subtitle (default: TRUE)
caption
Whether or not to remove the caption (default: TRUE)
x
Whether or not to remove the X axis title (default: TRUE)
y
Whether or not to remove the Y axis title (default: TRUE)

Value

A modified ggplot2 plot

Examples

Run this code
p <- ggplot(mtcars, aes(x = cyl, y = mpg)) +
    geom_point(shape = 1) +
    labs(title = "Fuel Efficiency by Engine Type",
         subtitle = "Larger engines are less efficient",
         caption = "Source: Motor Trend",
         x = "Number of Cylinders",
         y = "Fuel Efficiency (MPG)")
gg_remove_titles(plot = p)

Run the code above in your browser using DataLab