On 10/19/2009 5:28 AM, Cheryl Squair wrote:
I would like to wrap a y-axis label onto two lines. My label is an expression containing both text and math symbols. I have looked at plotmath, strsplit(), strwrap(), deparse(), do.call(), substitute() and bquote(). Based on previous posts, I can get plain text to wrap. However, when I try these methods on my label, the exact string is returned, rather than evaluating the math symbols.
You can't really get plotmath to wrap, as far as I know, but you can manually split a label to go onto two lines using atop. For example, with your setup I don't think your margins are big enough, but the following seems to work:
par(mar=c(6,8,6,1),cex.lab=1.3,cex.axis=1.2) plot(x,y, xlab=NA, ylab=expression(atop(paste("Saturating Irradiance, ", E[k], ",",mu,"\nmol"), paste(" photons ", m^-1," ", s^-1)))) Duncan Murdoch
My starting point: x<-c(1:10) y<-seq(5,50,5) par(mar=c(6,6,6,1),cex.lab=1.3,cex.axis=1.2) plot(x,y, xlab=NA, ylab=expression(paste("Saturating Irradiance, ",E[k],", ",mu,"mol photons ", m^-1," ", s^-1))) An unsuccessful example: plot(x,y, xlab=NA, ylab=strwrap(expression(paste("Saturating Irradiance, ",E[k],", ",mu,"mol photons ", m^-1," ", s^-1)), width=26)) I've tried so many iterations that I have thoroughly confused myself! I would appreciate any input on how to get the expression to wrap on two (or more, if I had a really long label) lines. I am using R version 2.9.2 (2009-08-24) on a Mac running OS X 10.5.8. Many thanks for your time.
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.