Hi, I have a the code for a plot that works perfectly running in R and printing to a Quartz object but which doesn't work when I make the trellis device a pdf. The code is as follows: ---- trellis.device(device="pdf", new=TRUE) trellis.par.set(my.theme()) dotplot(Y ~ X | C, groups=G, data=D, layout=c(2,1), ... ) trellis.focus("panel", 1, 1) for (y in 1:5) { panel.segments(...) } trellis.unfocus() trellis.focus("panel", 2, 1) for (y in 6:10) { panel.segments(...) } trellis.unfocus() dev.off() ---- The first for loop draws perfectly but the next panel never takes the focus and doesn't draw anything. The resulting file has the red focus box around the first panel still when the commands finish. Again, everything is fine when the device is a Quartz object. - Chris
Chris Poliquin <poliquin <at> sas.upenn.edu> writes:> > Hi, > > I have a the code for a plot that works perfectly running in R and > printing to a Quartz object but which doesn't work when I make the > trellis device a pdf. >Is this FAQ 7.22 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f ? (I'm not sure it is, but it might be) Ben Bolker
On Wed, Dec 31, 2008 at 3:41 PM, Chris Poliquin <poliquin at sas.upenn.edu> wrote:> Hi, > > I have a the code for a plot that works perfectly running in R and printing > to a Quartz object but which doesn't work when I make the trellis device a > pdf. > > The code is as follows: > ---- > > trellis.device(device="pdf", new=TRUE) > trellis.par.set(my.theme()) > dotplot(Y ~ X | C, groups=G, data=D, layout=c(2,1), ... ) > > trellis.focus("panel", 1, 1) > for (y in 1:5) { > panel.segments(...) > } > trellis.unfocus() > > trellis.focus("panel", 2, 1) > for (y in 6:10) { > panel.segments(...) > } > trellis.unfocus() > > dev.off() > > ---- > > The first for loop draws perfectly but the next panel never takes the focus > and doesn't draw anything. The resulting file has the red focus box around > the first panel still when the commands finish.Look more closely at your PDF file; it has more than one page. "Removing" graphical objects in grid (the red box in this case) has the effect of redrawing everything else in a new page. To avoid new pages, you need to avoid such removal, which in this case is as easy as trellis.focus("panel", 1, 1, highlight = FALSE) etc. -Deepayan
Possibly Parallel Threads
- trellis.focus with postscript device
- panel.abline() and trellis.focus() on multipage plots
- Focus on a sub-panel of a splom with trellis.focs() -- return coordinate of sub-panel, or names of variables therein
- Call to trellis.focus(); thenpanel.superpose()
- Lattice package - Trellis