Skip to content
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

Add ggplot_build() method for <ggplot_built> class #5803

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Mar 25, 2024

This PR aims to fix #5800.

Briefly, it does exactly what the title says and the method just returns input.
Due to this, we were allowed a small simplification to get_guide_data().

Reprex from issue:

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

head(layer_data(build))
#>     x  y PANEL group shape colour size fill alpha stroke
#> 1 1.8 29     1    -1    19  black  1.5   NA    NA    0.5
#> 2 1.8 29     1    -1    19  black  1.5   NA    NA    0.5
#> 3 2.0 31     1    -1    19  black  1.5   NA    NA    0.5
#> 4 2.0 30     1    -1    19  black  1.5   NA    NA    0.5
#> 5 2.8 26     1    -1    19  black  1.5   NA    NA    0.5
#> 6 2.8 26     1    -1    19  black  1.5   NA    NA    0.5
layer_grob(build)
#> [[1]]
#> points[geom_point.points.12]
layer_scales(build)
#> $x
#> <ScaleContinuousPosition>
#>  Range:   1.6 --    7
#>  Limits:  1.6 --    7
#> 
#> $y
#> <ScaleContinuousPosition>
#>  Range:    12 --   44
#>  Limits:   12 --   44

Created on 2024-03-25 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

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: implement ggplot_build.ggplot_built S3 method.
2 participants