Это фактически та же процедура, что и в python. Вот пример, полученный из this :
library(plotly)
df <- data.frame(x = 1:5,
y = 1:5)
# create steps for slider
steps <- list(
list(args = list("marker.color", "red"),
label = "Red",
method = "restyle",
value = "1"
),
list(args = list("marker.color", "green"),
label = "Green",
method = "restyle",
value = "2"
),
list(args = list("marker.color", "blue"),
label = "Blue",
method = "restyle",
value = "3"
)
)
p1 <- p2 <- df %>%
plot_ly(x = ~x, y = ~y,
mode = "markers",
marker = list(size = 20,
color = 'green'),
type = "scatter")
p <- subplot(p1, p2) %>%
layout(title = "Basic Slider",
sliders = list(
list(
active = 1,
currentvalue = list(prefix = "Color: "),
pad = list(t = 60),
steps = steps)))
p