Ottorino-Luca Pantani
2009-Dec-02 08:15 UTC
[R] Again on overlaying plots (a plot region within a plot region)
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 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
Petr PIKAL
2009-Dec-02 08:40 UTC
[R] Odp: Again on overlaying plots (a plot region within a plot region)
Hi r-help-bounces at r-project.org napsal dne 02.12.2009 09:15:05:> 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))Do not use T as a name for object as it can be confused with logical T/F par(fig=....) is what you want.> 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 2par(new=TRUE) par(fig=c(.3,.95,.4,.95))> 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")Regards Petr> > 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 > > 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 guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
Charlotte Maia
2009-Dec-02 09:26 UTC
[R] Again on overlaying plots (a plot region within a plot region)
Hi Ottorino-Luca, I'm not sure how flexible the layout command is off the top of my head. I have never seen an example of what you describe using layout, so I will assume it can't be done. One option is to use grid and lattice. This is possibly the best option if you are planning to do a lot of this sort of thing. Another option is to plot the second plot, on top of the first plot, using primitives such as points and lines, transforming your coordinates so that they match the coordinates of the first plot. This will be very difficult if you wish to put titles and axis on the nested plot, however simple if you restrict yourself to points and lines. Finding documentation and examples of R's graphical primitives should be easy. At the risk of sounding crude, I'm pretty sure both latex and many word processors allow one position one figure on top of another. This would seem the simplest solution for a one off job. Further to my post on R-devel, I recommend not using png format, except where absolutely necessary. regards -- Charlotte Maia http://sites.google.com/site/maiagx/home
David Winsemius
2009-Dec-02 13:14 UTC
[R] Again on overlaying plots (a plot region within a plot region)
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
Greg Snow
2009-Dec-02 18:47 UTC
[R] Again on overlaying plots (a plot region within a plot region)
Look at the subplot function in the TeachingDemos package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Ottorino-Luca Pantani > Sent: Wednesday, December 02, 2009 1:15 AM > To: ERRE > Subject: [R] Again on overlaying plots (a plot region within a plot > region) > > 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 > > 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.
Maybe Matching Threads
- on gsub (simple, but not to me!) sintax
- How to properly shade the background panels of an xyplot?
- dividing a dataframe column by different constants
- Is there in R a function equivalent to the mround, as found in most spreadsheets?
- substituting dots in the names of the columns (sub, gsub, regexpr)