本文介绍了R:ggplot2,我可以让facet / strip文字环绕吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现这个非常有用的代码来包装文本:
I found this very useful code for wrapping text here:
wrapper <- function(x, ...) paste(strwrap(x, ...), collapse = "\n")`
my_title <- "This is a really long title of a plot that I want to nicely wrap and fit onto the plot without having to manually add the backslash n, but at the moment it does not"
r + geom_smooth() + opts(title = wrapper(my_title, width = 20))
我想用它来包装文本在facet / strip中,但不要不知道如何。
I would like to use it to wrap the text in a facet/strip but don't know how.
p + geom_bar(stat="identity")+facet_wrap(~variable1) +
opts(strip.text.x=theme_text(size=12, face="bold")
Is it passed to the strip.text.x options?
推荐答案
由于此问题已发布,新的 label_wrap_gen() code>函数与
ggplot2
(> = 1.0.0,我想)处理这个很好:
facet_wrap(~variable1, labeller = label_wrap_gen())
这篇关于R:ggplot2,我可以让facet / strip文字环绕吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!