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

David Winsemius dwinsemius at comcast.net
Wed Dec 2 14:14:18 CET 2009


On Dec 2, 2009, at 3:15 AM, Ottorino-Luca Pantani wrote:

> 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.

The  subplot function in the excellent TeachingDemos package offer a  
complete solution.

http://finzi.psych.upenn.edu/R/library/TeachingDemos/html/subplot.html

-- 
David
>
> 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
>
> http://www.stat.auckland.ac.nz/~paul/RGraphics/custombase-pixmap.R
>
> 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 23.0.60.1 (x86_64-pc-linux-gnu, GTK+  
> Version 2.12.9)
> ESS version 5.5 -- R 2.10.0
>
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list