это, вероятно, подойдет вашим потребностям
пример данных
set.seed(357)
xy <- data.frame(letters = rep(c("a", "b", "c"), times = 3),
values = runif(9),
groups = rep(c("group1", "group2", "group3"), each = 3))
построение графика
#create a SharedData object for use in the ggplot below, group by 'groups'
d <- highlight_key(xy, ~groups )
#create a normal ggplot to fit your needs, but use the SharedData object as data for the chart
p <- ggplot( d, aes(x = letters, y = values, group = groups)) + theme_bw() + geom_point()
#now ggplotly the newly created ggplot, and add text for the tooltips as needed
gg <- ggplotly( p, tooltip = "groups" )
#set the highlight-options to your liking, and plot...
highlight( gg, on = "plotly_hover", off = "plotly_deselect", color = "red" )
результаты сюжета