Evaluate one or more ggplot2 expressions and attach the results as
"extras" on the state. Extras are folded into the plot during the next
runtime cycle when state$runtime()$ok is TRUE. Eval failures leave
the existing extras untouched.
Arguments
- state
A
ptr_statefromptr_init_state().- ...
ggplot2layer expressions (e.g.ptr_gg_extra(state, ggplot2::scale_x_log10(), theme_minimal())). Captured unevaluated and stored as quosures, then evaluated instate$eval_env. Eval errors propagate and leave the existing extras untouched (atomic update).
Examples
shiny::isolate({
state <- ptr_init_state(
"ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()"
)
state <- ptr_gg_extra(state, ggplot2::theme_minimal())
ptr_extract_code(state)
})
#> [1] ""
