[R] overlapping plots

Jim Lemon bitwrit at ozemail.com.au
Wed Nov 3 02:00:43 CET 2004


Carlisle Thacker wrote:
> Andy,
>
> If I had the three plots on three separate sheets of paper, I could cut
> out plot 2 and paste it over plot one so that the data and axes on both
> plots can be seen.  Then I could cut out plot 3 and past it over plots 1
> and 2 so that data and axes on all three plots can be seen.  For my
> special case, the x-axes would have to appear at the top of each plot.
> If there are boxes around the plots or guide lines, the parts below
> plots 2 and 3 should be obscured.
>
This is pretty rough, but I think it might be basically what you want.

par(mar=c(6,2,2,6))
plot(rnorm(20),rnorm(20),axes=FALSE,xlab="",ylab="")
axis(2)
axis(3)
par(new=TRUE)
par(mar=c(4,4,4,4))
plot(rnorm(10),type="l",col="green",axes=FALSE,xlab="",ylab="")
axis(2,col="green")
axis(3,col="green")
par(new=TRUE)
par(mar=c(2,6,6,2))
plot(rnorm(12),pch=2,col="red",axes=FALSE,xlab="",ylab="")
axis(2,col="red")
axis(3,col="red")

Jim




More information about the R-help mailing list