You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several getter functions, like layer_data(), call ggplot_build() on a plot.
For testing purposes, it might be more convenient to build a plot once and then extract relevant data/grobs/scales without having to build the plot every time.
Therefore, it can be convenient to have a ggplot_build.ggplot_built S3 method that just returns the input unaltered.
That way, it should be safe to use layer_data() or somesuch with a pre-build plot as input.
To express in code, I would like the following to work:
library(ggplot2)
p<- ggplot(mpg, aes(displ, hwy)) + geom_point()
build<- ggplot_build(p)
layer_data(build)
#> Error in UseMethod("ggplot_build"): no applicable method for 'ggplot_build' applied to an object of class "ggplot_built"
layer_grob(build)
#> Error in UseMethod("ggplot_build"): no applicable method for 'ggplot_build' applied to an object of class "ggplot_built"
layer_scales(build)
#> Error in UseMethod("ggplot_build"): no applicable method for 'ggplot_build' applied to an object of class "ggplot_built"
Several getter functions, like
layer_data()
, callggplot_build()
on a plot.For testing purposes, it might be more convenient to build a plot once and then extract relevant data/grobs/scales without having to build the plot every time.
Therefore, it can be convenient to have a
ggplot_build.ggplot_built
S3 method that just returns the input unaltered.That way, it should be safe to use
layer_data()
or somesuch with a pre-build plot as input.To express in code, I would like the following to work:
Created on 2024-03-25 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: