ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

Add `ggplot_build()` method for <ggplot_built> class

Open teunbrand opened this issue 3 months ago • 0 comments

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

teunbrand avatar Mar 25 '24 14:03 teunbrand