From maechler at stat.math.ethz.ch  Tue Apr 22 16:26:58 2008
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 22 Apr 2008 16:26:58 +0200
Subject: [Rd] graphics::Axis loosing S3/S4 class attributes of 'x' in
	2.7.0 RC
In-Reply-To: <1A68FCB28DE72F4BA3B967E6506CCE4302294883@mildnpexmb01.maninvestments.ad.man.com>
References: <1A68FCB28DE72F4BA3B967E6506CCE430229487F@mildnpexmb01.maninvestments.ad.man.com>
	<480DD38A.7090004@stats.uwo.ca>
	<1A68FCB28DE72F4BA3B967E6506CCE4302294881@mildnpexmb01.maninvestments.ad.man.com>
	<480DE708.3030104@stats.uwo.ca>
	<1A68FCB28DE72F4BA3B967E6506CCE4302294883@mildnpexmb01.maninvestments.ad.man.com>
Message-ID: <18445.62898.118580.497631@stat.math.ethz.ch>

>>>>> "OlegS" == Sklyar, Oleg \(MI London\) <osklyar at maninvestments.com>
>>>>>     on Tue, 22 Apr 2008 14:44:01 +0100 writes:

    OlegS> So if plot(x) produced rubbish in 2.6.2 in sense of axis formatting
    OlegS> would not that mean that either plot.POSIXct or in fact Axis.POSIXct is
    OlegS> incorrectly defined? I will have a look at those to see if I can find a
    OlegS> fix.

Me too.


    OlegS> Anyway, it does not seem to have any sense to argue any further, because
    OlegS> for me documented and logical are not the same things. 

It still makes much sense to discuss further.

I agree with you that the change 2.6.2 -> 2.7.0  fixed one problem
but introduced another one.

2.7.1 (and before that "2.7.0 patched") should hopefully be
better than both 2.6.2 and 2.7.0

My current version is

    if (axes) {
	localAxis(if(is.null(y)) xy$x else x, side = 1, ...)
	localAxis(if(is.null(y))  x   else y, side = 2, ...)
    }

which is I think better already than either predecessor;
it definitely is compatible with Rversion <= 2.6.2 when both
(x,y) are specified,
and it produces the correct axes in these three cases:

## Axis() calls via plot()
x <- as.Date("2008-04-22 09:45") + (i <- 0:4)
plot(x)# not ok in 2.6.2, nor 2.7.0
plot(x, i)# ok in 2.6.2  and 2.7.0
plot(i, x)# ok in 2.6.2 and not in 2.7.0


I'm grateful for further examples, preferably not using code
from packages outside of "standard R".

Martin Maechler, ETH Zurich


    OlegS> This "fix" effectively makes Axis.POSIXct and all other Axis.* methods
    OlegS> useless as there is now no despatch on Axis taking place in plot.default
    OlegS> and thus it is not clear why Axis and not Axis.default is actually used?
    OlegS> This would at least make the code cleaner. I was thinking that the idea
    OlegS> of methods is actually to have different implementations depending on
    OlegS> the argument class rather than coerce everything to double and use the
    OlegS> default instead.

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

    >> -----Original Message-----
    >> From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca] 
    >> Sent: 22 April 2008 14:24
    >> To: Sklyar, Oleg (MI London)
    >> Cc: R-devel at r-project.org
    >> Subject: Re: [Rd] graphics::Axis loosing S3/S4 class 
    >> attributes of 'x' in 2.7.0 RC
    >> 
    >> On 4/22/2008 9:08 AM, Sklyar, Oleg (MI London) wrote:
    >> > Duncan,
    >> > 
    >> > looking further, what has changed from 2.6.2 into 2.7.0 are the 
    >> > following two lines in plot.default, which I think were 
    >> logical before 
    >> > and are not really logical now:
    >> 
    >> I believe it is behaving as documented now, so the behaviour 
    >> is "logical", even if it may not be convenient.  In your example
    >> 
    >> x = Sys.time() + runif(100,1,7200) ## time over two hours, 
    >> POSIXct plot(x, 1:100) plot(1:100, x)
    >> 
    >> the 1st works in 2.6.2 and 2.7.0 and the second only works in 2.6.2. 
    >> But the change below was designed to fix the case
    >> 
    >> plot(x)
    >> 
    >> which works in 2.7.0 and *not* in 2.6.2, so reverting the 
    >> change is not the way to address this.
    >> 
    >> Duncan Murdoch
    >> 
    >> > 
    >> > plot.R: plot.default (2.6.2):
    >> > if (axes) {
    >> > 	localAxis(x, side=1, ...)
    >> > 	localAxis(y, side=2, ...)
    >> > }
    >> > 
    >> > plot.R: plot.default (2.7.0):
    >> > ...
    >> > if (axes) {
    >> > 	localAxis(xy$x, side=1, ...)
    >> > 	localAxis(xy$y, side=2, ...)
    >> > }
    >> > 
    >> > The fact that xy.coords is called does not really matter.
    >> > 
    >> > 
    [..............]



[Rd] graphics::Axis loosing S3/S4 class attributes of 'x' in 2.7.0 RC
Martin Maechler