Display geom_line in tooltip of ggplotly?

ggplotly works well to plotly-ify my plot and display the information within the tooltip when the bars are hovered over.

But how can I get the tooltip to display the red line as well? Like when you hover over the red line, you will see something like "lineval: 10"

Reprex:

library(ggplot2)
library(plotly)

mydf <- data.frame("name"=c("alice","bob","simon"),
                   "value"=c(5,10,12))

lineval <- 10

myplot <- ggplot(mydf, aes(x=name, y=value))+
  geom_col()+
  geom_hline(yintercept=lineval, color="red")

ggplotly(myplot)

Try group=1 in the aex() of ggplot2, I think that helped me once.

If you're looking for any other examples, you might find them here:

Or here

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.