[R] user coordinates and rug plots in lattice graphics

John Fox jfox at mcmaster.ca
Mon Apr 8 16:11:39 CEST 2002


Dear R list members,

I'd like to produce rug plots at the bottom of panels in a trellis display 
(using the lattice package), but par("usr") doesn't return user coordinates 
for panels, and consequently rug fails, as the following example (suggested 
to me by Georges Monette) illustrates:

     > x <- rnorm(50)
     > y <- rnorm(50)
     > f <- factor(sample(c('a','b','c'),size=50, replace=T))
     > z <- xyplot(y~x|f,
     +        panel = function(x,y,...) {
     +                panel.xyplot(x,y,...)
     +                rug(x)
     +                print(par('usr'))
     +        })
     > z
     [1] 0 1 0 1
     [1] 0 1 0 1
     [1] 0 1 0 1
     Warning messages:
     1: some values will be clipped in: rug(x)
     2: some values will be clipped in: rug(x)
     3: some values will be clipped in: rug(x)

(R Version 1.4.1 on a Windows 2000 PC.)

This code runs properly in S-PLUS, by the way, where par("usr") returns 
user coordinates when invoked within a panel function.

I don't see a way around the problem. If I could determine the minimum 
value of y in a panel, I could make my own rug plot. Any help would be 
greatly appreciated.

Thanks,
  John
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
-----------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list