Skip to content

Conversation

@teunbrand
Copy link
Collaborator

This PR aims to fix #4979 and conflicts with #5917.

Briefly, a new method is added to Facet to retrieve strip text after applying the labeller.

The new method is also used in FacetWrap/FacetGrid$draw_panels() to format the strip labels. As the labeller is already applied, the render_strips(labeller) argument has become vestigial. I haven't removed the argument as extensions might still use it.

Rendered example:

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

# Basic plot
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point()

get_strip_labels(p) # empty facets
#> NULL
get_strip_labels(p + facet_wrap(year ~ cyl))
#> $facets
#>   year cyl
#> 1 1999   4
#> 2 1999   6
#> 3 1999   8
#> 4 2008   4
#> 5 2008   5
#> 6 2008   6
#> 7 2008   8
get_strip_labels(p + facet_grid(year ~ cyl))
#> $cols
#>   cyl
#> 1   4
#> 2   5
#> 3   6
#> 4   8
#> 
#> $rows
#>   year
#> 1 1999
#> 2 2008

Created on 2024-05-31 with reprex v2.1.0

@thomasp85
Copy link
Member

With #5917 merged, does this needs to be updated or closed?

@teunbrand
Copy link
Collaborator Author

It has already been updated for #5917 in a4e646e

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

@teunbrand teunbrand merged commit e0bb6a3 into tidyverse:main Jul 11, 2024
@teunbrand teunbrand deleted the strip_label_accessor branch July 11, 2024 18:08
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.

view facet label text

2 participants