[R] plot order in multi-panel figure

Mark Lyman mark.lyman at atk.com
Fri Sep 19 17:32:24 CEST 2008


Stephen Tucker <brown_emu <at> yahoo.com> writes:

> Hi, 
> 
> Does anyone know if there is a way to 'reset the plot number' on a 
traditional graphics device?
> 
> For instance, I want to have two plots on stacked top of each other (mfrow=c
(2,1)) but with underlying grid
> lines spanning both figures vertically.


Below is one approach using split.screen. See ?split.screen for details.

> split.screen(c(1,1))
[1] 1
> screen(1)
> plot.window(c(0,1),c(0,1))
> abline(v=seq(0,1,by=0.2),lty=3)
> split.screen(c(2,1))
[1] 2 3
> screen(2)
> plot.new()
> plot.window(c(0,1),c(0,1))
> for(i in 1:2) axis(i)
> box(bty="L")
> rect(0.2,0.2,0.5,0.5,col=8)
> screen(3)
> plot.new()
> plot.window(c(0,1),c(0,1))
> for( i in 1:2) axis(i)
> box(bty="L")
> close.screen()
[1] 1 2 3

Mark Lyman



More information about the R-help mailing list