Re: [R] graphing plots of plots
In addition to the other suggestions you may also want to look at the subplot function in the TeachingDemos package (the version in Hmisc is a copy of a prior version of this one) as well as the my.symbols or panel.my.symbols functions in the same package. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Bernard Leemon Sent: Saturday, August 21, 2010 1:41 PM To: R-help@r-project.org Subject: [R] graphing plots of plots I want to make a graph where each element plotted is itself a graph. I can see how to use par(fig=) and viewport to do that, but they require (i think) me to do my own scaling as they are scaled to the graphics window. any advice on which approach I should take (just bite the bullet and do my own scaling), or is there something else I should try, or any examples I should look at. many thanks for any pointers. bernie leemon (aka gary mcclelland) [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] graphing plots of plots
I'm trying to understand your question because when I think of a graph, I think of one canvas, on which, various functions are plotted (a function can be one point for example). So, when you say each 'element' do you mean each function? If so, then that seems to be asking how to plot a function per graph (which is probably obvious and not what you're asking) How about you clarify first :) On Aug 21, 2010, at 12:40 PM, Bernard Leemon wrote: I want to make a graph where each element plotted is itself a graph. I can see how to use par(fig=) and viewport to do that, but they require (i think) me to do my own scaling as they are scaled to the graphics window. any advice on which approach I should take (just bite the bullet and do my own scaling), or is there something else I should try, or any examples I should look at. many thanks for any pointers. bernie leemon (aka gary mcclelland) [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] graphing plots of plots
We need a little bit of clarification. If you mean making a layout elements that are themselves graphs (i.e.a page with four graphs) then I like using ggplot2 for these types of things. hth Stephen Sefick On Sat, Aug 21, 2010 at 2:40 PM, Bernard Leemon bernie.lee...@gmail.com wrote: I want to make a graph where each element plotted is itself a graph. I can see how to use par(fig=) and viewport to do that, but they require (i think) me to do my own scaling as they are scaled to the graphics window. any advice on which approach I should take (just bite the bullet and do my own scaling), or is there something else I should try, or any examples I should look at. many thanks for any pointers. bernie leemon (aka gary mcclelland) [[alternative HTML version deleted]] __ R-help@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. -- Stephen Sefick | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___| | sas0...@auburn.edu | | http://www.auburn.edu/~sas0025 | |___| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@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.
Re: [R] graphing plots of plots
On Sat, Aug 21, 2010 at 8:48 PM, r.ookie r.oo...@live.com wrote: I'm trying to understand your question because when I think of a graph, I think of one canvas, on which, various functions are plotted (a function can be one point for example). So, when you say each 'element' do you mean each function? If so, then that seems to be asking how to plot a function per graph (which is probably obvious and not what you're asking) How about you clarify first :) Sounded to me a bit like plotting pie charts at the locations of countries on a map. Or something better (not hard). subplot from Hmisc? library(Hmisc) example(subplot) Barry __ R-help@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.
Re: [R] graphing plots of plots
The question isn't completely clear. I am guessing you want something like Figure 1.7 or Figure 7.18 in Paul Murrell's book. library(party) example(ctree) Rich On Sat, Aug 21, 2010 at 3:40 PM, Bernard Leemon bernie.lee...@gmail.comwrote: I want to make a graph where each element plotted is itself a graph. I can see how to use par(fig=) and viewport to do that, but they require (i think) me to do my own scaling as they are scaled to the graphics window. any advice on which approach I should take (just bite the bullet and do my own scaling), or is there something else I should try, or any examples I should look at. many thanks for any pointers. bernie leemon (aka gary mcclelland) [[alternative HTML version deleted]] __ R-help@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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] graphing plots of plots
Hi, I think you could do it quite easily with lattice, library(lattice) latticeGrob - function(p, ...){ grob(p=p, ..., cl=lattice) } drawDetails.lattice - function(x, recording=FALSE){ lattice:::plot.trellis(x$p, newpage=FALSE) } plots - replicate(4, xyplot(rnorm(10)~rnorm(10),xlab=,ylab=), simplify=F) my.vp - function(x,y) viewport(x=x,y=y,default.units=native,width=unit(1, cm), height=unit(1,cm)) my.panel = function(x, y, ...){ ind - seq_along(x) for (ii in ind){ g - latticeGrob(plots[[ii]], vp=my.vp(x[ii],y[ii])) grid.draw(g) } } xyplot(1:4~1:4, panel = my.panel) HTH, baptiste On 21 August 2010 22:11, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Sat, Aug 21, 2010 at 8:48 PM, r.ookie r.oo...@live.com wrote: I'm trying to understand your question because when I think of a graph, I think of one canvas, on which, various functions are plotted (a function can be one point for example). So, when you say each 'element' do you mean each function? If so, then that seems to be asking how to plot a function per graph (which is probably obvious and not what you're asking) How about you clarify first :) Sounded to me a bit like plotting pie charts at the locations of countries on a map. Or something better (not hard). subplot from Hmisc? library(Hmisc) example(subplot) Barry __ R-help@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. __ R-help@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.
Re: [R] graphing plots of plots
I'm glad he asked that question, I found Barry's and your suggestion useful for myself. Thanks! (R surprises me every day). On Aug 21, 2010, at 1:12 PM, RICHARD M. HEIBERGER wrote: The question isn't completely clear. I am guessing you want something like Figure 1.7 or Figure 7.18 in Paul Murrell's book. library(party) example(ctree) Rich On Sat, Aug 21, 2010 at 3:40 PM, Bernard Leemon bernie.lee...@gmail.comwrote: I want to make a graph where each element plotted is itself a graph. I can see how to use par(fig=) and viewport to do that, but they require (i think) me to do my own scaling as they are scaled to the graphics window. any advice on which approach I should take (just bite the bullet and do my own scaling), or is there something else I should try, or any examples I should look at. many thanks for any pointers. bernie leemon (aka gary mcclelland) [[alternative HTML version deleted]] __ R-help@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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@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. __ R-help@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.
Re: [R] graphing plots of plots
Once you load library(grid) the rest works. Nice job :) Dennis On Sat, Aug 21, 2010 at 1:15 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, I think you could do it quite easily with lattice, library(lattice) latticeGrob - function(p, ...){ grob(p=p, ..., cl=lattice) } drawDetails.lattice - function(x, recording=FALSE){ lattice:::plot.trellis(x$p, newpage=FALSE) } plots - replicate(4, xyplot(rnorm(10)~rnorm(10),xlab=,ylab=), simplify=F) my.vp - function(x,y) viewport(x=x,y=y,default.units=native,width=unit(1, cm), height=unit(1,cm)) my.panel = function(x, y, ...){ ind - seq_along(x) for (ii in ind){ g - latticeGrob(plots[[ii]], vp=my.vp(x[ii],y[ii])) grid.draw(g) } } xyplot(1:4~1:4, panel = my.panel) HTH, baptiste On 21 August 2010 22:11, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Sat, Aug 21, 2010 at 8:48 PM, r.ookie r.oo...@live.com wrote: I'm trying to understand your question because when I think of a graph, I think of one canvas, on which, various functions are plotted (a function can be one point for example). So, when you say each 'element' do you mean each function? If so, then that seems to be asking how to plot a function per graph (which is probably obvious and not what you're asking) How about you clarify first :) Sounded to me a bit like plotting pie charts at the locations of countries on a map. Or something better (not hard). subplot from Hmisc? library(Hmisc) example(subplot) Barry __ R-help@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. __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] graphing plots of plots
many useful suggestions that I'll work on, especially babtiste's detailed code. yes, I want something like Fig 1.7, or 7.18, or 7.22, but where the x,y values are characteristics of the mini-histogram that is plotted. attached (if it makes it through) is what i'm trying to do in R. On Sat, Aug 21, 2010 at 4:08 PM, Dennis Murphy djmu...@gmail.com wrote: Once you load library(grid) the rest works. Nice job :) Dennis On Sat, Aug 21, 2010 at 1:15 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, I think you could do it quite easily with lattice, library(lattice) latticeGrob - function(p, ...){ grob(p=p, ..., cl=lattice) } drawDetails.lattice - function(x, recording=FALSE){ lattice:::plot.trellis(x$p, newpage=FALSE) } plots - replicate(4, xyplot(rnorm(10)~rnorm(10),xlab=,ylab=), simplify=F) my.vp - function(x,y) viewport(x=x,y=y,default.units=native,width=unit(1, cm), height=unit(1,cm)) my.panel = function(x, y, ...){ ind - seq_along(x) for (ii in ind){ g - latticeGrob(plots[[ii]], vp=my.vp(x[ii],y[ii])) grid.draw(g) } } xyplot(1:4~1:4, panel = my.panel) HTH, baptiste On 21 August 2010 22:11, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Sat, Aug 21, 2010 at 8:48 PM, r.ookie r.oo...@live.com wrote: I'm trying to understand your question because when I think of a graph, I think of one canvas, on which, various functions are plotted (a function can be one point for example). So, when you say each 'element' do you mean each function? If so, then that seems to be asking how to plot a function per graph (which is probably obvious and not what you're asking) How about you clarify first :) Sounded to me a bit like plotting pie charts at the locations of countries on a map. Or something better (not hard). subplot from Hmisc? library(Hmisc) example(subplot) Barry __ R-help@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. __ R-help@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. [[alternative HTML version deleted]] __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.
Re: [R] graphing plots of plots
I've now tried Babtiste's code and my reaction is WOW! it shows me how to do just what I need to do. I know enough to follow all the code but it would have taken me a LOOO time to generate it. thank you Babtiste! gary On Sat, Aug 21, 2010 at 2:15 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, I think you could do it quite easily with lattice, library(lattice) latticeGrob - function(p, ...){ grob(p=p, ..., cl=lattice) } drawDetails.lattice - function(x, recording=FALSE){ lattice:::plot.trellis(x$p, newpage=FALSE) } plots - replicate(4, xyplot(rnorm(10)~rnorm(10),xlab=,ylab=), simplify=F) my.vp - function(x,y) viewport(x=x,y=y,default.units=native,width=unit(1, cm), height=unit(1,cm)) my.panel = function(x, y, ...){ ind - seq_along(x) for (ii in ind){ g - latticeGrob(plots[[ii]], vp=my.vp(x[ii],y[ii])) grid.draw(g) } } xyplot(1:4~1:4, panel = my.panel) HTH, baptiste On 21 August 2010 22:11, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Sat, Aug 21, 2010 at 8:48 PM, r.ookie r.oo...@live.com wrote: I'm trying to understand your question because when I think of a graph, I think of one canvas, on which, various functions are plotted (a function can be one point for example). So, when you say each 'element' do you mean each function? If so, then that seems to be asking how to plot a function per graph (which is probably obvious and not what you're asking) How about you clarify first :) Sounded to me a bit like plotting pie charts at the locations of countries on a map. Or something better (not hard). subplot from Hmisc? library(Hmisc) example(subplot) Barry __ R-help@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. __ R-help@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. [[alternative HTML version deleted]] __ R-help@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.