Although base graphics does not mix with lattice in the one graph, I've found that print.trellis(position=..., ) and the use of par(fig=...) to put regular and trellis graphics on the one graphics page works like a treat, at least in version 2.0.1 of R. [Base graphics functions that are themselves inconsistent with par(fig=...) are obviously disallowed.] I am wondering whether there are caveats of which I and others should be aware, or whether there is a risk that the ongoing development of R's graphics abilities will render such a cohabitation unworkably fractious. Example: gph <- bwplot(voice.part ~ height, data=singer) print(gph, position=c(0, 0.5, 1, 1)) # x0, y0, x1, y1 par(fig=c(0, 1, 0,0.5), new=TRUE) # x0, x1, y0, y1 boxplot(height ~ voice.part, data=singer, horiz=TRUE) John Maindonald email: john.maindonald at anu.edu.au phone : +61 2 (6125)3473 fax : +61 2(6125)5549 Centre for Bioinformation Science, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200.
Base and lattice graphics on the same graphics page
3 messages · John Maindonald, Deepayan Sarkar, Paul Murrell
On Tuesday 29 March 2005 22:32, John Maindonald wrote:
Although base graphics does not mix with lattice in the one graph, I've found that print.trellis(position=..., ) and the use of par(fig=...) to put regular and trellis graphics on the one graphics page works like a treat, at least in version 2.0.1 of R. [Base graphics functions that are themselves inconsistent with par(fig=...) are obviously disallowed.] I am wondering whether there are caveats of which I and others should be aware, or whether there is a risk that the ongoing development of R's graphics abilities will render such a cohabitation unworkably fractious.
Paul would know better, but I think that's unlikely. In fact, the gridBase package allows you to do use grid (and hence lattice) functions to add to a base plot, as well as (I didn't realize this before) the other way round. The only caveat is that resizing the device may mess things up. You may have to be careful with new devices. Your example pasted on a fresh session (tested only on r-devel) starts a new page for the boxplot since it thinks that new=TRUE doesn't make sense (because there's no 'old' plot yet). Deepayan
Hi
Deepayan Sarkar wrote:
On Tuesday 29 March 2005 22:32, John Maindonald wrote:
Although base graphics does not mix with lattice in the one graph, I've found that print.trellis(position=..., ) and the use of par(fig=...) to put regular and trellis graphics on the one graphics page works like a treat, at least in version 2.0.1 of R. [Base graphics functions that are themselves inconsistent with par(fig=...) are obviously disallowed.] I am wondering whether there are caveats of which I and others should be aware, or whether there is a risk that the ongoing development of R's graphics abilities will render such a cohabitation unworkably fractious.
Paul would know better, but I think that's unlikely. In fact, the gridBase package allows you to do use grid (and hence lattice) functions to add to a base plot, as well as (I didn't realize this before) the other way round. The only caveat is that resizing the device may mess things up.
Yep, sounds like you're doing exactly the sort of thing that gridBase does. See R News 3(2) for a discussion. Paul
You may have to be careful with new devices. Your example pasted on a fresh session (tested only on r-devel) starts a new page for the boxplot since it thinks that new=TRUE doesn't make sense (because there's no 'old' plot yet). Deepayan
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/