I try to customize the orientation and text alignment of a tooltip in a plotly-graphic generated using ggplot and ggplotly. However, I am not able to achieve this and would be glad if somebody could help me.
Goal is to have a tooltip on top of the values and with left-orientation.
I tried various options and looked through the documentation of plotly, but however was not able to get the right option for orientation.
Find below an example code:
library(ggplot2)
library(plotly)
df = data.frame(x = c(1, 2, 3),
y = c(1.1, 2.1, 1.1))
p1 <-
ggplot(df, aes(x = x,
y = y,
text = paste0('x :', x, '\n',
'y :', y))) +
geom_point()
ggplotly(p1, tooltip = "text") %>%
style(hoverlabel = list(bgcolor = "white",
bordercolor = "#77777",
font = list(color = '#77777'),
align = "left", # THIS IS NOT WORKING
orientation = "h" # THIS IS NOT WORKING
)
)
I would be glad, if you could help me fix the orientation of the tooltip to be on top and the text alignment to be left-aligned.
Thanks a lot in advance!
David