[R] help with the use of mtext to create main title over multiple plots
David Winsemius
dwinsemius at comcast.net
Mon Oct 12 19:46:19 CEST 2009
On Oct 12, 2009, at 1:41 PM, Tony Plate wrote:
> Try playing around with the "oma" setting in par() -- it sets the
> outer margins, which by default are zero.
>
> The following shows the mtext label for me, using the windows device:
>
>> par(mfrow=c(2,2))
>> par("oma")
> [1] 0 0 0 0
>> par("oma"=c(0,0,2,0))
>> for (i in 1:4) plot(0:1,0:1)
>> mtext(text = "my test plots", side = 3, outer = TRUE)
Good advice. Works on a Mac, too:
setwd("~/Desktop")
pdf("my.test.plots.pdf", paper = "letter")
opar <- par(mfrow=c(2,2), oma=c(0,0,2,0))
for (i in 1:4){
plot(1:6, 1:6);
}
mtext(text = "my test plots", side = 3, outer = TRUE)
dev.off(); par(opar)
>>
>
> Mark Kimpel wrote:
>> I'm trying to use mtext to create a main title over multiple plots.
>> Below is
>> a simple self-contained example and my sessionInfo (I should note
>> I've also
>> tried this with R-2.8.1 with the same results). When I execute the
>> code
>> chunk below, I get the plots, but no title. I've tried this using
>> the screen
>> driver, pdf, and postscript. I've used different sizes of paper. I
>> suspect I
>> am making an elementary error but searching the help files and help
>> archives
>> hasn't provided me an answer.
>> Thanks for any help, Mark
>> #############################################
>> setwd("~/Desktop")
>> pdf("my.test.plots.pdf", paper = "letter")
>> par(mfrow=c(2,2))
>> for (i in 1:4){
>> plot(1:6, 1:6)
>> }
>> mtext(text = "my test plots", side = 3, outer = TRUE)
>> dev.off()
>> #
>> R version 2.10.0 Under development (unstable) (2009-09-21 r49771)
>> x86_64-unknown-linux-gnu
>> locale:
>> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
>> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
>> [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
>> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
>> [9] LC_ADDRESS=C LC_TELEPHONE=C
>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>> other attached packages:
>> [1] car_1.2-15
>> loaded via a namespace (and not attached):
>> [1] tools_2.10.0
>> Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry
>> Indiana University School of Medicine
>> 15032 Hunter Court, Westfield, IN 46074
>> (317) 490-5129 Work, & Mobile & VoiceMail
>> (317) 399-1219 Skype No Voicemail please
>> [[alternative HTML version deleted]]
>> ______________________________________________
--
>
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list