Consider the simple example below. Is there a way to format the plotly tooltip such that the long text labels are visible in a box, rather than this absurd rectangle that cuts off values?
library(ggplot2); library(plotly)
df <- data.frame(x = 1:10, y = 1:10, z = rep("the longggggggggggggggggggggggggggggestttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt labelllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll you can imagineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", 10))
p <- ggplot(df, aes(x,y,label=z)) + geom_point()
ggplotly(p, tooltip = "label")
I'm pretty sure, that the more elegant solution somewhere exists. I can just suggest you to put a break like every
n
character. There is a nice workaround from https://stackoverflow.com/a/2352006/9300556:So we just need to add
gsub()
intoggplot
aesthetics:UPDATE
Here is a more elegant solution from the comments by @Rich Pauloo. In this case your strings also will be mostly left padded (but actually auto-aligned). However, the padding depends on plot resolution and label location.