Greg is absolutely right: Generally base and grid graphics(which is what
lattice plots are based on) don't play well together, and gridBase is meant
to address this.

However...
The problem here is specifically that the print.trellis (or synonymous
plot.trellis) function that is silently invoked to display the xyplot does
not "know" about the layout; but it has options that you can use to tell it
about it so that you may be able to fiddle with to get something suitable
without going all the way to gridBase, e.g.

layout(matrix(1:2,nr=1)) ## 1 row 2 columns
plot(1:10)
## explicitly call the plot.trellis function with "new" 
## and "split" arguments set
plot(xyplot(rnorm(10) ~ 1:10),new=FALSE, split=c(2,1,2,1))

Note that the layout() indexing and split indexing are backwards: layout
indices are number of rows and columns; while split indexing given number of
x positions and y positions = number of columns and rows.

Probably the best approach to this in general is to do everything in lattice
and use grid viewports to position the plots. But I admit this requires
climbing a learning curve.

HTH.

Bert Gunter
Genentech Nonclinical Biostatistics


-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Greg Snow
Sent: Thursday, June 18, 2009 8:33 AM
To: Titus v. d. Malsburg; r-help@r-project.org
Subject: Re: [R] "Normal" plot and xyplot side by side in one figure?

Look at the gridBase 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 Titus v. d. Malsburg
> Sent: Thursday, June 18, 2009 7:29 AM
> To: r-help@r-project.org
> Subject: [R] "Normal" plot and xyplot side by side in one figure?
> 
> Hi list,
> 
> I want to place a plot (eg "plot(1:10)") and a xyplot side by side in
> one figure.  The two columns should have different widths.  If I'm not
> missing something, this rules out the standard way: par(mfcol=n).
> 
> I tried layout(), but it doesn't seem to like it when grid scribbles
> into its views (the plot works but the view for the xyplot is left
> empty).
> 
> I would appreciate any ideas!  Thanks in advance.
> 
>   Titus
> 
> ______________________________________________
> 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.

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

Reply via email to