library(ggplot2)
library(plotly)
gg <- ggplot(mtcars, aes(factor(vs), drat)) +
geom_violin() +
geom_jitter()
ggplotly(gg)
In example code we use ggplot
to plot violin and jitter layers. Plotly
displays information for both layers (i.e. when hovered over jitter point it will display specific point information, same thing happens when hovered over the violin plot). However, I want plotly
to display information only for geom_jitter
.
Question: How to disable hovered information for specific layer?
You can set the hoverinfo
to "none"
for that geom
:
gg <- ggplot(mtcars, aes(factor(vs), drat)) +
geom_violin() +
geom_jitter()
ggply <- ggplotly(gg)
ggply$x$data[[1]]$hoverinfo <- "none"
ggply
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With