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))
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?
Since this question was posted, the new label_wrap_gen()
function with ggplot2
(>= 1.0.0, I think) handles this nicely:
facet_wrap(~variable1, labeller = label_wrap_gen())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With