[R] add lines() to 1st plot in layout() after calling 2nd plot()?

Marianne Promberger marianne.promberger at kcl.ac.uk
Sat Oct 3 21:15:27 CEST 2009

Dear R users,

I create a graphic with two plots side by side using layout(), like this:

plot(1:10,main="left plot")
plot(10:1,main="right plot")

The lines() obivously get added to the "left plot" plot.

Now, I'm trying to write a function that builds up a plot bit by bit to
then include it in a LaTeX presentation with overlays. I'm using
dev.copy(), and it would make my life much easier (because in fact I
call all sorts of additional axis() etc after plot) if I could call
the above commands in this order:

plot(1:10,main="left plot")
plot(10:1,main="right plot")

but of course now lines() gets added to the "right plot". I

Is there any way to make the lines() go to the fist plot ("left plot")?


Marianne Promberger PhD, King's College London
R version 2.9.2 (2009-08-24)
Ubuntu 9.04

More information about the R-help mailing list