remove_axis: Removes one or both axes of a 'ggplot2' plot

View source: R/remove-axis.R

remove_axisR Documentation

Removes one or both axes of a ggplot2 plot

Description

A helper function to set axis.line, axis.ticks, axis.text and axis.title elements to element_blank() for the specified axis.

Usage

remove_axis(axis = "y")

Arguments

axis

Specifies the axis to remove. One of "x", "y", "xy". Default is "y" because my most common use case is for density plots.

Examples

library(ggplot2)
library(dplyr)
library(palmerpenguins)

p <- penguins %>%
  filter(!is.na(flipper_length_mm)) %>%
  ggplot(aes(x = flipper_length_mm)) +
  geom_density(aes(fill = species), alpha = 0.5) +
  scale_fill_brewer(palette = "Set1") +
  scale_y_continuous(expand = expansion(c(0, 0.1))) +
  labs(x = "Flipper length (mm)")
p + theme_td() +
  remove_axis("y")

taylordunn/dunnr documentation built on Aug. 8, 2022, 12:28 p.m.