This function evaluates an expression representing a ggplot construction code. It specifically uses the environment stored in the 'ggcall_env' attribute of the expression, ensuring that the plot is reconstructed in the correct context.

eval_ggcall(call, ...)

Arguments

call

An expression representing the ggplot construction call, typically generated by `ggcall()`. This expression should have an attribute 'ggcall_env' that stores the environment in which the plot was originally created.

...

Additional variables passed to the evaluation environment.

Value

The resulting ggplot object produced by evaluating the expression `x`.

Examples

library(ggplot2, exclude = "ggplot")

func <- function() {
  ggplot(mtcars, aes(x = wt, y = mpg)) +
    geom_point()
}
gplot <- func()
plot_call <- ggcall(gplot)
reconstructed_plot <- eval_ggcall(plot_call)
print(reconstructed_plot)