[R] Plotting second axes outside xyplot
Paul Murrell
p.murrell at auckland.ac.nz
Fri Jun 17 04:07:09 CEST 2005
Hi
Andrew Robinson wrote:
> Hi all,
>
> I'm trying to find a way to get xyplot to produce a second set of axes outside the right hand side of the graph. This is my progress so far:
>
> EE <- equal.count(ethanol$E, number=9, overlap=1/4)
> xyplot(NOx ~ C | EE, data = ethanol,
> prepanel = function(x, y) prepanel.loess(x, y, span = 1),
> xlab = "Compression Ratio", ylab = "NOx (micrograms/J)",
> panel = function(x, y) {
> panel.grid(h=-1, v= 2)
> panel.xyplot(x, y)
> panel.loess(x,y, span=1)
> panel.axis(side = "right", at = c(1, 3),
> labels = c(1, 3), outside = T)
> },
> aspect = "xy")
>
> Does anyone have any suggestions?
I suspect the output from panel.axis() is getting clipped. You might
get it to work as follows ...
EE <- equal.count(ethanol$E, number=9, overlap=1/4)
xyplot(NOx ~ C | EE, data = ethanol,
prepanel = function(x, y) {
prepanel.loess(x, y, span = 1)
},
xlab = "Compression Ratio",
ylab = "NOx (micrograms/J)",
panel = function(x, y) {
panel.grid(h=-1, v= 2)
panel.xyplot(x, y)
panel.loess(x,y, span=1)
# don't call panel.axis in here
},
aspect = "xy")
# return to the right-most panel WITH CLIPPING OFF
trellis.focus("panel", 9, 1, clip.off=TRUE)
# draw the extra axis
panel.axis(side = "right", at = c(1, 3),
labels = c(1, 3), outside = T)
trellis.unfocus()
Paul
--
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/
More information about the R-help
mailing list