Skip to content
Prev 28486 / 63468 Next

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

Thanks Duncan,

this might explain why Axis.MyClass is never called.

However, it is really not only illogical to define plot.MyClass instead
of Axis.MyClass if the only thing I want is formatting of the axis, but
it is also broken in R 2.7.0 and here is why.

Let's forget about MyClass and take POSIXct, for which plot.POSIXct and
Axis.POSIXct are defined in graphics. First question would be, why
define Axis.POSIXct if it is logical to just define plot.POSIXct. But
then, try the following example in 2.7.0 and 2.6.2:

x = Sys.time() + runif(100,1,7200) ## time over two hours, POSIXct
plot(x,1:100)
plot(1:100,x)

The first plot will be correctly formatted in both R versions while the
second one will be *incorrectly* formatted in 2.7.0 (funny enough
xy.coords returns as.double in both, so that might not be the reason for
the problem).

What happens is that plot.POSIXct is called in the former case and thus
we get the correct formatting. However, plot.default is called in the
latter case. In 2.6.2 Axis.POSIXct was the reason why y axis was
correctly formatted here. In 2.7.0 Axis.default is called instead
because class of x is reset.

Now this perfectly indicates why it is logical to have Axis.MyClass
defined (as this two-liner would be called in all possible situations
producing correct axes independently where it is called from) and not
plot.MyClass (which would actually not cover the situation of only the
second argument being MyClass). Surely I can define S4 with multiple
signatures, but logically I would define Axis.MyClass.

Omitting axes completely is not a good options to enforce on users for
default plots, is it?


Dr Oleg Sklyar
Technology Group
Man Investments Ltd
+44 (0)20 7144 3803
osklyar at maninvestments.com