Plotly offers the option to display a moveable horizontal or vertical "spikeline" by adding layout(hovermode = "x unified")
or layout(hovermode = "y unified")
(see documentation). For example:
library(plotly)
x <- seq(from = 0, to = 2*pi, length = 100)
y <- sin(x)
fig <- plot_ly(x = x, y = y, type = "scatter", mode = "markers")
fig <- fig %>% layout(hovermode = "x unified")
fig
creates this plot with a vertical line that follows the cursor:
I would like to have both the vertical and the horizontal spikeline displayed. Like this:
I tried to modify the layout like this:
fig <- fig %>% layout(hovermode = "x unified") %>% layout(hovermode = "y unified")
# or
fig <- fig %>% layout(hovermode = c("x unified", "y unified"))
# or
fig <- fig %>% layout(hovermode = "x unified|y unified")
None of this worked. Would anybody have a suggestion?