[R] margin text mtext
Paul Murrell
paul at stat.auckland.ac.nz
Mon Jun 11 07:03:02 CEST 2001
Hi
> Fiddling around with "mar" and "mtext" I got stuck:
>
> plot.pcaX <- function(tit,lab) {
> on.exit(par(oldpar <- par(oma=c(4, 2, 4, 2), mar = c(4, 4, 2, 1)))) # ??
> split.screen(figs=c(3,3))
> for (i in 1:9) {screen(i); plot(rnorm(100),rnorm(100)) }
> mtext(tit, side = 3, line = 1, outer = TRUE, cex = 1.5, adj = 0.5)
> mtext(paste(lab,", ", date()),side = 1,line=0,outer=TRUE,cex=0.5,adj=1)
> close.screen(all=T)
> }
>
> plot.pcaX("test","test.ps")
>
> The plots are arranged without any margins, and "test" and "test.ps" will
> not be printed on the plot.
A couple of things ...
(i) the code within on.exit() is not executed until the function exits
which is why your margins are not affected during the function call
(ii) you should probably be using par(mfrow) instead of screen() et al
A suggested modification of your function is:
plot.pcaX <- function(tit,lab) {
oldpar <- par(oma=c(4, 2, 4, 2), mar = c(4, 4, 2, 1)) # ??
on.exit(par(oldpar)) # ??
par(mfrow=c(3,3))
for (i in 1:9) { plot(rnorm(100),rnorm(100)) }
mtext(tit, side = 3, line = 1, outer = TRUE, cex = 1.5, adj = 0.5)
mtext(paste(lab,", ", date()),side = 1,line=0,outer=TRUE,cex=0.5,adj=1)
}
Hope that helps
Paul
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list