I have been playing around with plotOutput("plot_click") in Shiny. It seems pretty straightforward in most plots. Rather than returning the pixel x and pixel y value for a mouse click, it returns the x and y value scaled to the plot of interest for a mouse click. A app.R example is below -
library(shiny)
ui <- basicPage(
plotOutput("plot1", click = "plot_click"),
verbatimTextOutput("info")
)
server <- function(input, output) {
output$plot1 <- renderPlot({
qplot(mtcars$wt, mtcars$mpg)
})
output$info <- renderText({
paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y)
})
}
shinyApp(ui, server)
I would like to extend upon this functionality so that I can obtain the x and y value scaled to a subplot of interest for a mouse click. I am interested in this when working with plot matrices. An app.R example is below -
library(shiny)
ui <- basicPage(
plotOutput("plot1", click = "plot_click"),
verbatimTextOutput("info")
)
server <- function(input, output) {
data <- select(mtcars,wt,mpg,qsec)
output$plot1 <- renderPlot({
ggpairs(data)
})
output$info <- renderText({
paste0("x=", input$plot_click$x, "\ny=", input$plot_click$y)
})
}
shinyApp(ui, server)
I am only interested in the bottom-left three subplots. When I mouse click at any area of these bottom-left three subplots, however, I get the x and y values scaled for the entire plot. Is it possible to change this so that I could get the values for the x and y values scaled for each subplot accurately? Note: I am not interested in any points outside of these three bottom left subplots, and would not care to loose their interactive functionality if needed. Please kindly share any ideas!