这是提取点击事件的工作示例。我想问你是否有办法通过增加大小或突出显示等来更新点击点?
library(shiny)
library(plotly)
ui <- fluidPage(
plotlyOutput("plot"),
verbatimTextOutput("click")
)
server <- function(input, output, session) {
nms <- row.names(mtcars)
output$plot <- renderPlotly({
p <- ggplot(mtcars, aes(x = mpg, y = wt, col = as.factor(cyl), key = nms)) +
geom_point()
ggplotly(p)
})
output$click <- renderPrint({
d <- event_data("plotly_click")
if (is.null(d)) "Click events appear here (double-click to clear)"
else cat("Selected point associated with Car: ", d$key)
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
我已经搜索了 SO 和其他合适的来源以找到以下问题的解决方案,但找不到。
更新:
已在此处询问有关更改单击点形状的相关问题。