gpt4 book ai didi

R:ggplot2,我可以让 facet/strip 文本环绕吗?

转载 作者:行者123 更新时间:2023-12-04 17:12:52 28 4
gpt4 key购买 nike

我发现这个非常有用的文本换行代码 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 中,但不知道如何。
 p + geom_bar(stat="identity")+facet_wrap(~variable1) + 
opts(strip.text.x=theme_text(size=12, face="bold")

它是否传递给 strip.text.x 选项?

最佳答案

自从发布了这个问题,新的 label_wrap_gen()功能与 ggplot2 (>= 1.0.0,我认为) 处理得很好:

facet_wrap(~variable1, labeller = label_wrap_gen())

关于R:ggplot2,我可以让 facet/strip 文本环绕吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5574157/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com