plotly: Updating data with dropdown selection

强颜欢笑 提交于 2019-11-29 05:09:40

Is this what you were after?

require(plotly)
df <- data.frame(x = runif(200), y = runif(200), z = runif(200))
p <- plot_ly(df, x = ~x, y = ~y, mode = "markers", name = "A", visible = T) %>%
layout(
  title = "Drop down menus - Styling",
  xaxis = list(domain = c(0.1, 1)),
  yaxis = list(title = "y"),
  updatemenus = list(
    list(
      y = 0.7,
      buttons = list(
        list(method = "restyle",
             args = list("y", list(df$y)),  # put it in a list
             label = "Show A"),
        list(method = "restyle",
             args = list("y", list(df$z)),  # put it in a list
             label = "Show B")))
))
p
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!