When rendering a ggplot that contains geom_text with vjust argument, the vjust argument is ignored.
There are multiple geom_text lines that refer to different text values from the data. I want the same vertical hover effect when rendering the plot with ggpotly.
Here is the reprex
# data
df <-
data.frame(x = (.75), y =(1.1)) %>%
cbind(data.frame(a = seq(0, 1, 0.1))) %>%
cbind(as_tibble(runif(11), 11, 1))
# plot
gg <-
ggplot(data = df, aes(x = value, y = a)) +
geom_segment(aes(x=0, y=a, xend= 1, yend=a), color="cadetblue3", size=2) +
geom_point(aes(x = 0, y =a), size = 4) +
geom_text(aes(x = 0, y = a, label = x), col= "blue", vjust = 2) +
geom_point(aes(x = 1, y = a), size = 4) +
geom_text(aes(x = 1, y = a, label = a), col = "red", vjust = 2) +
geom_point(aes(x = value, y = a), size = 4, col = "forestgreen", alpha = 0.5) +
geom_text(aes(x = value, y = a, label = round(value, 2)), size = 4, col = "forestgreen", vjust = -1) +
theme_void()
# interactive
ggplotly(gg)