Suppose I am building a plotly scatterplot that displays three different groups (here specified by colour). I can show/hide each group individually by clicking at the groups in the legend.
library(ggplot2)
library(plotly)
d <- data.frame("a" = sample(1:50, 20, T), "b" = sample(1:50, 20, T),
"col" = factor(sample(1:3, 20, T)))
gg <- ggplot() + geom_point(aes(x = a, y = b, color = col), data = d)
gg
plotly_build(gg)
Is there a way to add a button to the legend to show/hide all points ?