【发布时间】:2020-04-09 13:58:43
【问题描述】:
我有一个像下面这样的情节,我需要在其中显示情节标题和一些长的刻面标签。在ggplot2,看起来还不错。
代表:
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
但是,转换为动态图并没有按预期工作...构面标签被切断并进入标题:
gp <- ggplotly(g)
gp
有一个previous SO question about this,但看起来 OP 没有尝试答案 - 没有人发现建议的答案没有按预期工作。
我对@987654330@ 在涉及方面时的奇怪行为并不陌生 - 请参阅对话here on github,但我不知道plotly 足以修改对象以强制它具有更长的strip.background。
希望有人可以帮我修改gp的对象以寻求解决方案。
【问题讨论】:
标签: r ggplot2 r-plotly facet-wrap ggplotly