tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.5k stars 2.02k forks source link

In `facet_grid`, could the `switch` argument be deprecated, and replaced with a `strip.position` argument? #5999

Open davidhodge931 opened 3 months ago

davidhodge931 commented 3 months ago

I find it a bit confusing having the strip.position/switch argument in facet_wrap/facet_grid that does pretty much the same thing.

An idea to make these consistent is to deprecate the switch argument in facet_grid, and add in a strip.position argument for users to use instead.

Where in a grid of 2 facet variables, a character vector of 2 could be provided with "top"/"bottom" always controlling the x, and "left"/"right" would always controlling the y.

Also, It'd be cool if for the grid, it didn't matter which way around you specify the vector - as it would always know top/bottom relates to cols facet variable and right/left to the rows facet variable.

penguins |> 
   ggplot() +
   geom_point(aes(x = flipper_length_mm, y = body_mass_g)) +
   facet_grid(.~species, strip.position = "bottom")

 penguins |> 
   ggplot() +
   geom_point(aes(x = flipper_length_mm, y = body_mass_g)) +
   facet_grid(sex~species, strip.position = c("bottom", "left"))
teunbrand commented 3 months ago

I empathise with the consistency argument, but I don't think the current sistuation is creating enough friction to justify the trouble of changing this argument.

davidhodge931 commented 3 months ago

It'd also be good to get consistency now, before there is many extension facet functions - so that when developers make these they all use the same named argument to represent this concept.

Feel free to close if you're still are not persuaded