webr
webr copied to clipboard
Any way to replot last or selected plot
I need to implement functionality to replot (like in RStudio for ecample) last or selected plot instead of scale it. Any ideas how to do it ? I try this
.plot_history <- list()
.log_plot <- function(expr, value, succeeded, visible) {
if (dev.cur() > 1) {
dev.control("enable")
.plot_history[[length(.plot_history) + 1]] <<- recordPlot()
}
return(TRUE)
}
addTaskCallback(.log_plot, name = "plot_logger")
plot(rnorm(100), main = "Random dots")
last_plot <- .plot_history[[length(.plot_history)]]
replayPlot(last_plot)
But nothing returns. Any ideas ?