[R] plot help

Henrique Dallazuanna wwwhsd at gmail.com
Thu Jan 24 11:18:51 CET 2008


Try this:

#some data
y1=rnorm(1:3)
y2=rnorm(1:3)

#draw two plots on the same screen
par(mfrow=c(2,1),oma = c(6, 0, 5, 0))
par(mar=c(0, 5.1, 0, 5.1))
plot(y1,xaxt="n",type="n") #1st plot
par(mar=c(0, 5.1, 0, 5.1))
plot(y2,xaxt="n",type="n") #2nd plot

 #try to draw lines onto each plot on the screen
 lines(y2) #draws a line in the 2nd plot
 par(mfg=c(1, 1))
 lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I


On 24/01/2008, tom soyer <tom.soyer at gmail.com> wrote:
> Hi,
>
> Suppose I already have two plots on the same screen, and I want to draw
> lines in each of them. Is that possible in R? It seems that once you have
> two plots on the screen, you can only draw lines in the the last plot, never
> the 1st. Here is what I mean:
>
> #some data
> y1=rnorm(1:3)
> y2=rnorm(1:3)
>
> #draw two plots on the same screen
> par(mfrow=c(2,1),oma = c(6, 0, 5, 0))
> par(mar=c(0, 5.1, 0, 5.1))
> plot(y1,xaxt="n",type="n") #1st plot
> par(mar=c(0, 5.1, 0, 5.1))
> plot(y2,xaxt="n",type="n") #2nd plot
>
> #try to draw lines onto each plot on the screen
> lines(y2) #draws a line in the 2nd plot
> lines(y1,col=2) #also draws a line in the 2nd plot, but that's not what I
> want. I want to draw the line in the 1st plot instead.
>
> Does anyone know if after more than one plot were drawn, can I still call
> the 1st plot and draw a line in it?
>
> Thanks,
>
> --
> Tom
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list