[R] Again on overlaying plots (a plot region within a plot region)

Ottorino-Luca Pantani ottorino-luca.pantani at unifi.it
Wed Dec 2 09:15:05 CET 2009

Dear R-users,
after seeking for help in R-search
I did not find any hint on my particular problem.
Countless help on "true" overlay, but nothing on this.

Please consider the following:

par(mfrow = c(2, 1))
T <- seq(0, 20, by = 0.01)
## PLOT 1
plot(T,  30*exp(-0.65*T),
     type = "l"
points(T, 30*exp(-0.26 * T), type = "l", lty = "F8")
points(T, 30*exp(-0.15 * T), type = "l", lty = "39")
## PLOT 2
plot(T,  30*exp(-0.65*T),
     type = "l",
     log= "y"
points(T, 30*exp(-0.26 * T), type = "l", lty = "F8")
points(T, 30*exp(-0.15 * T), type = "l", lty = "39")

What I would like to do is to draw a square plot of PLOT 1 and
then overlay the *entire* PLOT 2 on the upper right corner of PLOT 1,
when there's a lot of empty space
I have to do that because the publisher asked me not to waste
much space with figures.

I studied for some time the Paul Murrell's excellent book "R Graphics",
but I did not find what I'm looking for.

As far as I understand, layout() is intended to flexibly
divide the plot region, not to subdivide the plot region
nor the figure region.

One solution could be to export PLOT 1 , say as png,
and then overlay on it PLOT 2 with pixmap() as in this example


but it seems to me a bit too much complicate

Thanks in advance for your time

Ottorino-Luca Pantani, Università di Firenze
Dip. Scienza del Suolo e Nutrizione della Pianta
P.zle Cascine 28 50144 Firenze Italia
Ubuntu 8.04.3 LTS -- GNU Emacs (x86_64-pc-linux-gnu, GTK+ 
Version 2.12.9)
ESS version 5.5 -- R 2.10.0

More information about the R-help mailing list