How to change the opacity of the unselected points on a plotly scatterplot?

43 Views Asked by At

My code is below. I want to make it so that when I select a particular provider from the key, the points which weren't selected (i.e. the other providers) just fade slightly (i.e. the opacity is reduced slightly) so that you can still see them and hover over them and use the tooltip.

y_intercept = 0.5

p1 <- df %>% filter(Specialty == "Sarcoma") %>%
ggplot(aes(x=X, y=Y, Provider = Provider, Specialty = Specialty)) +
  geom_point(aes(col = Provider, size = PTL)) +
  theme_minimal() +
  geom_hline(yintercept = y_intercept) +
  labs(title = "TITLE",
       x = "X",
        y = "Y",
       color = "ORG")

ggplotly(p1, tooltip = c("Provider", "Specialty"))

I've found documentation which seems to relate to what I want to do (see opacity of unselected here: https://plotly.com/r/reference/parcoords/#parcoords-unselected) but I can't figure out what this would look like in the code as there are no examples.

0

There are 0 best solutions below