[R] help with the use of mtext to create main title over multiple plots
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-8LC_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]] __ 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.
Re: [R] help with the use of mtext to create main title over multiple plots
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) 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-8LC_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]] __ 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. __ 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.
Re: [R] help with the use of mtext to create main title over multiple plots
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-8LC_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 __ 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.
Re: [R] help with the use of mtext to create main title over multiple plots
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 ... Thanks for your nice example showing the problem clearly. I normally prefer to test these things in a window first, it's faster, though. You had forgotten to give the poor graphics a bit of outer margin. If you look carefully, you could have seen a few tail in the plot. The example overreacts a bit, but you get the idea. You might also reduce your plot margins a bit (see par) to avoid to large empty space. Dieter par(mfrow=c(2,2),oma=c(10,10,10,10) for (i in 1:4){ plot(1:6, 1:6) } mtext(text = my test plots, side = 1, outer = TRUE) -- View this message in context: http://www.nabble.com/help-with-the-use-of-mtext-to-create-main-title-over-multiple-plots-tp25859951p25860178.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] help with the use of mtext to create main title over multiple plots
Hey Mark, The text is actually there -- I can just see the bottom of the 'y' and the 'p' in my plotting window. You can move the text down (into the plot) with the argument line. E.g.: mtext(text = my test plots, side = 3, outer = TRUE, line=-2) Hope that helps... - Simon Bonner Post-Doctoral Fellow Department of Statistics, UBC www.simon.bonners.ca On Mon, 2009-10-12 at 13:29 -0400, Mark Kimpel wrote: mtext(text = my test plots, side = 3, outer = TRUE) __ 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.
Re: [R] help with the use of mtext to create main title over multiple plots
Thanks Tony (and others). Setting oma corrects the problem. Mark 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 On Mon, Oct 12, 2009 at 1:41 PM, Tony Plate tpl...@acm.org 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) 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-8LC_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]] __ 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. [[alternative HTML version deleted]] __ 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.