2

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

david_zrh
  • 23
  • 4
  • looks like there may be some issue for align with hoverlabel here: https://stackoverflow.com/questions/50003531/r-plotly-hover-label-text-alignment ... also, orientation not part of hoverlabel, and applies to stackgroup https://plot.ly/r/reference/ – Ben May 24 '19 at 18:29
  • Seems to be working now – william3031 Dec 30 '20 at 05:49

0 Answers0