I've got a plot like the one below, where I need to display a plot title and some long facet labels. In ggplot2
, it looks just fine.
Reprex:
library(ggplot2)
library(stringr)
library(plotly)
iris$Species2 <- paste(iris$Species, "... some text to make the label really long and hard to put on a facet label")
iris$Species2 <- str_wrap(iris$Species2, 20)
g <- ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
geom_point() +
labs(title = "This title isn't helping anyone") +
facet_wrap(~Species2)
g
However, converting to a dynamic plot is not working as expected... the facet labels get cut off and run into the title:
gp <- ggplotly(g)
gp
There's a previous SO question about this, but it looks like the OP didn't try the answer - no one caught that the suggested answer doesn't work as expected.
I'm no stranger to plotly
having strange behaviour when facets are involved - see conversation here on github, but I don't know plotly
well enough to modify an object to force it to have a longer strip.background.
Hoping someone can help me modify the object gp
for a solution.