Re: [R] Plotting second axes outside xyplot

From: Paul Murrell <p.murrell_at_auckland.ac.nz>
Date: Fri 17 Jun 2005 - 12:07:09 EST

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@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
R-help@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
Received on Fri Jun 17 12:11:50 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:44 EST