Skip to content

More sorting options for facet_wrap() #5855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 29, 2024
Merged

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5212.

Briefly, it adds more options for the dir argument to layout the panels in various ways. The as.table argument gets absorbed into dir when the previous way of declaring dir = "v" or dir = "h" is used.

The new options for dir are:

  • "lt": start in the top-left, start filling left-to-right.
  • "tl": start in the top-left, start filling top-to-bottom.
  • "lb": start in the bottom-left, start filling left-to-right.
  • "bl": start in the bottom-left, start filling bottom-to-top.
  • "rt": start in the top-right, start filling right-to-left.
  • "tr": start in the top-right, start filling top-to-bottom.
  • "rb": start in the bottom-right, start filling right-to-left.
  • "br" start in the bottom-right, start filling bottom-to-top

Using as.table with any of the options above has no effect.

As an example where blank panels are set at the beginning:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

ggplot(mpg, aes(displ, hwy)) +
  geom_point() +
  facet_wrap(~ class, dir = "rb")

Created on 2024-04-22 with reprex v2.1.0

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Maybe add an example with the new features

@teunbrand
Copy link
Collaborator Author

Good idea thanks!

@teunbrand teunbrand merged commit 8fa0fb4 into tidyverse:main Apr 29, 2024
7 of 12 checks passed
@teunbrand teunbrand deleted the facet_sorting branch April 29, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: allow blank panels of facet_wrap() to be at the beginning
2 participants