I'm trying to implement zoom-in feature in plot (usual ggplot2 and base R plot) used in shiny renderplot module. Here is the code.
ui <- basicPage(
plotOutput("plot1",
brush = "plot_brush"
)
)
server <- function(input, output) {
output$plot1 <- renderPlot({
plot(mtcars$wt, mtcars$mpg, xlim = c(input$plot_brush$xmin, input$plot_brush$xmax), ylim=c(input$plot_brush$ymin, input$plot_brush$ymax))
})
}
shinyApp(ui, server)
Here I want to set the input : - input$plot_brush to NULL after the zoom is applied. I know this will be requiring modification in the renderPlot block of the code but apart from that how can I set input$plot_brush to NULL [which will make the selection disappear from the plot]. I know update input functions are there in order to update UI [like shiny::updateSelectInput() etc] but those can't be used here for this purpose.
Right now only one way to solve this is to have a base plot and a zoomed plot where zoom will be applied after selecting a region on base plot [as implemented in https://gallery.shinyapps.io/105-plot-interaction-zoom/].
Please help me on this.