[R] Plotting second axes outside xyplot

Andrew Robinson andrewr at uidaho.edu
Fri Jun 17 10:43:16 CEST 2005


Paul,

thanks!  An elegant solution.  
Andrew

--
Andrew Robinson                      Ph: 208 885 7115
Department of Forest Resources       Fa: 208 885 6226
University of Idaho                  E : andrewr at uidaho.edu
PO Box 441133                        W : http://www.uidaho.edu/~andrewr
Moscow ID 83843                      Or: http://www.biometrics.uidaho.edu
No statement above necessarily represents my employer's opinion.



----- Original Message -----
From: Paul Murrell <p.murrell at auckland.ac.nz>
Date: Thursday, June 16, 2005 7:07 pm
Subject: Re: [R] Plotting second axes outside xyplot

> 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