ggeasy icon indicating copy to clipboard operation
ggeasy copied to clipboard

Feature request: make functions relating to removing/changing axes able to work on top/bottom/both or left/right/both

Open davidhodge931 opened this issue 1 year ago • 2 comments

davidhodge931 avatar Jan 14 '24 23:01 davidhodge931

Could you add an example of what you'd start with and what the result would be? It might only require a slight change to the which argument.

jonocarroll avatar Jan 14 '24 23:01 jonocarroll

library(tidyverse)
library(palmerpenguins)

p <- penguins |> 
  ggplot(aes(x = flipper_length_mm, y = body_mass_g)) +
  geom_point() +
  facet_wrap(~species, strip.position = "bottom") +
  theme_classic() +
  scale_x_continuous(sec.axis = dup_axis())

p
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).


#I would like to be able to do this
# p +
#   ggeasy::easy_remove_axes(which = "x.bottom")

#and acheive this
p +
  theme(
    axis.ticks.x.bottom = element_blank(),
    axis.title.x.bottom = element_blank(),
    axis.text.x.bottom = element_blank(),
    axis.line.x.bottom = element_blank()
  )
#> Warning: Removed 2 rows containing missing values or values outside the scale range
#> (`geom_point()`).

Created on 2024-01-15 with reprex v2.1.0

davidhodge931 avatar Jan 15 '24 00:01 davidhodge931