Hello everyone,
I would like to know if it is possible to add combined argument in the dropdown menu feature that was implemented in R. In the following example I modified the sin/con tutorial example. I just change the restyle line.colour option with a relayout yaxis.range option.
So my question now. Is it possible to combine in one button both the restyle (visible) and relayout (yaxis.range) effects?
library(plotly)
x <- seq(-2*pi, 2*pi, length.out = 1000)
df <- data.frame(x, y1 = sin(x), y2 = cos(x))
p <- plot_ly(df, x = ~x) %>%
add_lines(y = ~y1, name = "A") %>%
add_lines(y = ~y2, name = "B", visible = F)
p <- p %>% layout(
title = "Drop down menus - Styling",
xaxis = list(domain = c(0.1, 1)),
yaxis = list(title = "y"),
updatemenus = list(
list(
y = 0.8,
buttons = list(
list(method = "relayout",
args = list("yaxis.range", as.list(c(-0.5,0.5))),
label = "0.5 yaxis"),
list(method = "relayout",
args = list("yaxis.range", as.list(c(-1,1))),
label = "1.0 yaxis"))),
list(
y = 0.7,
buttons = list(
list(method = "restyle",
args = list("visible", list(TRUE, FALSE)),
label = "Sin"),
list(method = "restyle",
args = list("visible", list(FALSE, TRUE)),
label = "Cos")))
))