F Duan
2004-Jul-30 15:41 UTC
[R] How to put multiple plots in the same window? (not par(mfrow=))
Dear All, I am sorry if this question has been asked before. Below is my Question: I want to put several plots in the same window, but I don?t want the blank space between plots (like par(mfrow=)) --- that makes the plots too small. Could anyone tell me how to do it? Thanks a lot. Frank
Thomas Lumley
2004-Jul-30 15:49 UTC
[R] How to put multiple plots in the same window? (not par(mfrow=))
On Fri, 30 Jul 2004, F Duan wrote:> Dear All, > > I am sorry if this question has been asked before. Below is my Question: > > I want to put several plots in the same window, but I don?t want the blank > space between plots (like par(mfrow=)) --- that makes the plots too small. > Could anyone tell me how to do it? >There isn't blank space between the plots. There is blank space around each plot. The amount of space around each plot is controlled by par(mar), which specifies the number of lines of space on each side of the plotting area The default is> par("mar")[1] 5.1 4.1 4.1 2.1 and if you do, say, par(mar=c(3.1,3.1,1,1)) you will have much less blank space. You need to make sure enough space is left for axis label &c. -thomas
Sundar Dorai-Raj
2004-Jul-30 15:49 UTC
[R] How to put multiple plots in the same window? (not par(mfrow=))
F Duan wrote:> Dear All, > > I am sorry if this question has been asked before. Below is my Question: > > I want to put several plots in the same window, but I don?t want the blank > space between plots (like par(mfrow=)) --- that makes the plots too small. > Could anyone tell me how to do it? > > Thanks a lot. > > Frank >You should definitely use package:lattice. --sundar
Uwe Ligges
2004-Jul-30 16:00 UTC
[R] How to put multiple plots in the same window? (not par(mfrow=))
F Duan wrote:> Dear All, > > I am sorry if this question has been asked before. Below is my Question: > > I want to put several plots in the same window, but I don?t want the blank > space between plots (like par(mfrow=)) --- that makes the plots too small. > Could anyone tell me how to do it?E.g. with par(mfrow=...)! There is no blank space between the plots, just the inner margins. And you can control inner margins with par(mar=...). Uwe Ligges> Thanks a lot. > > Frank > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Sean Davis
2004-Jul-30 16:00 UTC
[R] How to put multiple plots in the same window? (not par(mfrow=))
Frank, Why not try using grid graphics? You can open arbitrary viewports into which to place plots. Sean On Jul 30, 2004, at 11:41 AM, F Duan wrote:> Dear All, > > I am sorry if this question has been asked before. Below is my > Question: > > I want to put several plots in the same window, but I don?t want the > blank > space between plots (like par(mfrow=)) --- that makes the plots too > small. > Could anyone tell me how to do it? > > Thanks a lot. > > Frank > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
Marc Schwartz
2004-Jul-30 16:08 UTC
[R] How to put multiple plots in the same window? (not par(mfrow=))
On Fri, 2004-07-30 at 10:41, F Duan wrote:> Dear All, > > I am sorry if this question has been asked before. Below is my Question: > > I want to put several plots in the same window, but I dont want the blank > space between plots (like par(mfrow=)) --- that makes the plots too small. > Could anyone tell me how to do it? > > Thanks a lot. > > FrankIt is not clear if you want a matrix of plots or if you want plots that actually overlap (ie. inset plots). For example, for a matrix using par("mfrow"), the actual figure regions for each plot fill up the full plotting device: par(mfrow = c(2, 2)) plot(1:5) box(which = "figure") plot(1:5) box(which = "figure") plot(1:5) box(which = "figure") plot(1:5) box(which = "figure") Each of the four plots take up one quarter of the overall device. The outer four boxes represent the figure region for each of the four plots. Within each figure region is the plot region and the axes, labels, etc. for each individual plot. You can use par("mar") to reduce the amount of space between the plot region and the figure region. As an extreme example: par(mfrow = c(2, 2)) par(mar = c(0, 0, 0, 0)) plot(1:5) box(which = "figure") plot(1:5) box(which = "figure") plot(1:5) box(which = "figure") plot(1:5) box(which = "figure") In this case, you now would need to play around with the axis tick marks, labels, etc. Can you clarify which space you are referring to? Marc Schwartz
Gavin Simpson
2004-Jul-30 16:27 UTC
[R] How to put multiple plots in the same window? (not par(mfrow=))
F Duan wrote:> Dear All, > > I am sorry if this question has been asked before. Below is my Question: > > I want to put several plots in the same window, but I don?t want the blank > space between plots (like par(mfrow=)) --- that makes the plots too small. > Could anyone tell me how to do it? > > Thanks a lot. > > Frank?split.screen ?layout are alternatives to par(mfrow = c()), but I think you need to look at the margins of the plots and reduce them to suit your purposes. See ?par and argument mar. For example: oldpar <- par(mfrow = c(2,2), mar = c(3,3,1,1) + 0.1) plot(1:10) plot(1:10) plot(1:10) plot(1:10) par(oldpar) # or layout(matrix(c(1,2,3,4), 2, 2, byrow = TRUE)) layout.show(4) oldpar <- par(mar=c(3,3,1,1) + 0.1) plot(1:10) plot(1:10) plot(1:10) plot(1:10) par(oldpar) There is no room for labels/titles but adjust the mar to suit your requirements. Gav -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. & ECRC [E] gavin.simpson at ucl.ac.uk UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%