library(plotly)
library(crosstalk)

m <- SharedData$new(mtcars, ~cyl)
p <- ggplot(m, aes(wt, mpg)) + geom_point() + facet_wrap(~vs)

highlight(
  ggplotly(p),
  defaultValues = "4",
  color = "red",
  selected = attrs_selected(marker = list(size = 10))
)
d <- subset(txhousing, city %in% c("Galveston", "Midland", "Odessa", "South Padre Island"))
sd <- SharedData$new(d, ~year)
p <- ggplot(sd, aes(month, median, group = year)) + geom_line() +
  facet_wrap(~city, ncol = 2)
gg <- ggplotly(p, tooltip = "year")
highlight(gg, defaultValues = "2006")
## Setting the `off` event (i.e., 'plotly_doubleclick') to match the `on` event (i.e., 'plotly_click'). You can change this default via the `highlight()` function.