I want to show only one trace at the beginning of a grouped bar chart in Plotly for R and then progressively reveal more traces when clicking on the legend.
Here is an example:
df <- data.frame(
Category = c("A", "B", "C", "D"),
group1= c(10, 20, 15, 30),
group2= c(15, 25, 20, 35)
)
bar_plot <- plot_ly(df, x = ~Category) %>%
add_trace(y = ~group1, name = "Group 1", type = 'bar') %>%
add_trace(y = ~group2, name = "Group 2", type = 'bar') %>%
layout(barmode = 'group')
bar_plot
Now, it would be great to only have group1 shown at the beginning as default.
Is that possible?
Thanks a lot!
Got trough all possible specifications, was not able to figure it out.
change the second trace to