gg_remove_titles: Remove titles from a plot

Description Usage Arguments Value Examples

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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

1
2
3
4
5
6
7
8
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)

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