I'm trying to create a ggiraph plot that I would like to include in a rmarkdown document where hovering the legend will also highlight the corresponding points in the plot.
I've tried below code, but while I can hover the points in the plot and the legend they are not linked. Is there a way to link these?
library(ggiraph)
library(ggplot2)
p = ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species, data_id = Species)) +
geom_point_interactive() +
scale_color_brewer_interactive(palette = 'Set1',
data_id = function(breaks) as.character(breaks))
p = girafe(ggobj = p)
p = girafe_options(p,
opts_hover(girafe_css("stroke:black;fill:black;")),
opts_hover_key(girafe_css("stroke:black;fill:black")))
print(p)