[R] problems with arrangement of figures by layout function

Greg Snow Greg.Snow at imail.org
Wed Feb 25 23:08:09 CET 2009


The plot of the tree uses base graphics (works with layout).  The histogram function is a lattice/trellis graph that uses grid graphics (at least the histogram function that I am aware of).

Unfortunately base and grid graphics do not play nicely together without some additional steps.  Some options to try:

Use the hist function (base graphics) instead of histogram.

Use the gridBase package (functions to help grid and base get along).

Use the plot function with the result of histogram and set the pos and newpage parameters and hope/experiment to get things to line up.

Pray for a miracle.


Hope this helps,

-- 
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 Weidong Gu
> Sent: Wednesday, February 25, 2009 2:48 PM
> To: r-help at r-project.org
> Subject: [R] problems with arrangement of figures by layout function
> 
> Hi,
> 
> I want to have histograms behind the regression tree figure.
> 
> Since 7 leafs resulted from the tree model (rpart), it would be nice to
> have correspondent histograms below the tree figure. After a little
> study, I could generate the correspondent histogram for each leaf, but
> can't figure out how to arrange them in the right place. I tried
> something like
> 
> >layout(rbind(c(1,1,1,1,1,1,1),c(2,3,4,5,6,7,8)))# the first row for
> tree
> >plot(tree,uniform=T,branch=0.5,margin=0,compress=T)
> >histogram(IncU|where)
> 
> But the last command ignores the layout arrangement. How can I get
> around the problem?
> 
> Thanks in advance
> 
> Weidong Gu
> Department of Medicine
> UAB
> 
> 
> 
> ______________________________________________
> 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.




More information about the R-help mailing list