Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Highlight a line in simple line graph through dropdown

I’m trying to add a dropdown button so that I can select one trace to highlight. A simplified version of my code in R is below. I have seen how to add a dropdown to change the style from say line to bar, but I don’t know how to change the style for just one id. Thanks!

library(tidyverse)
library(plotly)
set.seed(2001)

make 10 random data series

data <- data.frame(
t = rep(1:50, 10),
id = sort(rep(1:10, 50)),
y = rnorm(500)
)

cumulate the random variates by group

data <- data %>%
group_by(id) %>%
mutate(y2 = cumsum(y))

plot

plot <- data %>%
plot_ly(x = ~ t, y = ~y2, text = ~id) %>%
add_lines(split = ~id, color = I(‘gray’), alpha = 0.5) %>%
hide_legend()
plot

Probably best to ask this question on #api/r