Skip to content

Text wrap

4 messages · Philippe Massicotte, David Winsemius, Marc Schwartz

#
Hi everyone.

I have a long label that I would like to split. I found that I could use
"strwrap" for simple text. However, this is not working with this label:

str = expression(paste("< 20 ?m phytoplankton ","(cells ? ",mL^-1,")"))

plot(...., ylab = strwrap(str,20),...)

I suspect this is because I'm using "expression" for form my label.

I also tried with \n but this is not working either.

Regards,
Phil

--
View this message in context: http://r.789695.n4.nabble.com/Text-wrap-tp3747574p3747574.html
Sent from the R help mailing list archive at Nabble.com.
#
On Aug 16, 2011, at 11:39 AM, Filoche wrote:

            
And the plotmath page warns you that it won't work

Have you looked at 'atop'?
Perhaps something like this ... after making an effort to interpret  
your incompletely describe goals:

plot(1,1, sub= expression(atop("< 20 ?m phytoplankton  
","(cells?mL"^-1*")")))

You had two commas in that origial express and it wasn't at all clear  
why.
#
On Aug 16, 2011, at 10:39 AM, Filoche wrote:

            
plotmath expressions do not support new lines within the expression. From ?plotmath:

 "Control characters (e.g. \n) are not interpreted in character strings in plotmath, unlike normal plotting."

You would need to create each line as a separate expression and use ?mtext, if you wish, to place each line along the axis, using the 'line' argument for placement/spacing.

HTH,

Marc Schwartz