Skip to content

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5989.

Briefly, summary.ggplot() no longer prints the whole facet ggproto object, but rather prints the variables used for facetting.

Some examples with various facets:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
p <- ggplot(mpg, aes(displ, hwy)) +
  geom_point()

summary(p)
#> data: manufacturer, model, displ, year, cyl, trans, drv, cty, hwy, fl,
#>   class [234x11]
#> mapping:  x = ~displ, y = ~hwy
#> faceting:  <empty> 
#> -----------------------------------
#> geom_point: na.rm = FALSE
#> stat_identity: na.rm = FALSE
#> position_identity

summary(p + facet_wrap(~drv))
#> data: manufacturer, model, displ, year, cyl, trans, drv, cty, hwy, fl,
#>   class [234x11]
#> mapping:  x = ~displ, y = ~hwy
#> faceting:  ~drv 
#> -----------------------------------
#> geom_point: na.rm = FALSE
#> stat_identity: na.rm = FALSE
#> position_identity

summary(p + facet_grid(drv ~ year))
#> data: manufacturer, model, displ, year, cyl, trans, drv, cty, hwy, fl,
#>   class [234x11]
#> mapping:  x = ~displ, y = ~hwy
#> faceting:  ~drv, ~year 
#> -----------------------------------
#> geom_point: na.rm = FALSE
#> stat_identity: na.rm = FALSE
#> position_identity

# Reasonable results for extension facets
summary(p + ggforce::facet_matrix(~drv))
#> data: manufacturer, model, displ, year, cyl, trans, drv, cty, hwy, fl,
#>   class [234x11]
#> mapping:  x = ~displ, y = ~hwy
#> faceting:  ~row_data, ~col_data 
#> -----------------------------------
#> geom_point: na.rm = FALSE
#> stat_identity: na.rm = FALSE
#> position_identity

Created on 2024-09-04 with reprex v2.1.1

Copy link
Member

@yutannihilation yutannihilation left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@teunbrand teunbrand merged commit 8c724a4 into tidyverse:main Sep 9, 2024
13 checks passed
@teunbrand
Copy link
Collaborator Author

Thanks for the review!

@teunbrand teunbrand deleted the summary_facets branch September 9, 2024 11:12
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.

summary() is verbose about facet

2 participants