Skip to content
Prev 28485 / 63468 Next

graphics::Axis loosing S3/S4 class attributes of 'x' in 2.7.0 RC

On 22/04/2008 7:25 AM, Sklyar, Oleg (MI London) wrote:
If you look at plot.default, you'll see it passes x and y through 
xy.coords to get coordinates.  That function ends with

return(list(x=as.double(x), y=as.double(y), xlab=xlab, ylab=ylab))

so that's where classes get removed.  If you don't want this to happen, 
shouldn't you be defining plot.MyClass, or calling the default with 
axes=F, and then calling Axis on your object yourself?
This is documented:  ?plot.default tells you to look at ?xy.coords for 
details of how x and y are handled, and xy.coords
says "In any other case, the 'x' argument is coerced to a vector and
      returned as *y* component where the resulting 'x' is just the
      index vector '1:n'.  In this case, the resulting 'xlab' component
      is set to '"Index"'."

Duncan Murdoch