[R] How to put multiple plots in the same window? (not par(mfrow=))
Marc Schwartz
MSchwartz at MedAnalytics.com
Fri Jul 30 18:08:21 CEST 2004
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.
>
> Frank
It 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
More information about the R-help
mailing list