[Rd] plot.POSIXct

Duncan Murdoch
Thu, 12 Oct 2006 13:33:34 -0000

On 10/12/2006 9:08 AM, Armstrong, Whit wrote:
> I've never had any issues with the way that plot.POSIXct chooses the
> labels of the date axis before, but in this particular case it's output
> is a little confusing.

It was wrong, but this was fixed in R-patched last week.  I've added an
item to NEWS about it.

Duncan Murdoch

>
>
plot(seq(as.POSIXct("1997-10-01"),length.out=108,by="month"),rnorm(108))
>
> This command produces a chart with every x tick mark labeled as "Jan
> 01".
>
> I can replicate this chart by adding the format string "%b %d".
>
>
plot(seq(as.POSIXct("1997-10-01"),length.out=108,by="month"),rnorm(108),
> format="%b-%d")
>
> My contention is that plot.POSIXct should choose "%Y" in this
case,
> which would show unique labels rather than repeated labels.
>
>
plot(seq(as.POSIXct("1997-10-01"),length.out=108,by="month"),rnorm(108),
> format="%Y")
>
>
>
> Now, just looking at axis.POSIXct it seems that the terminal condition
> of this if/else sequence sets format to "%b %d":
>
>  }
>     else if (d < 7 * 60 * 60 * 24) {
>         sc <- 60 * 60 * 24
>         if (missing(format))
>             format <- "%a"
>     }
>     else {
>         sc <- 60 * 60 * 24
>         if (missing(format))
>             format <- "%b %d"  #****** here
>     }
>
>
> when the second set of if conditions fires up, format has already bet
> set, so the missing(format) test fails here and does not set the format
> to %Y:
>
>  else {
>         class(z) <- c("POSIXt", "POSIXct")
>         zz <- as.POSIXlt(z)
>         zz$mday <- 1
>         zz$isdst <- zz$mon <- zz$hour <- zz$min <- zz$sec <-
0
>         zz$year <- pretty(zz$year)
>         z <- as.POSIXct(zz)
>         if (missing(format))
>             format <- "%Y"   #******  here
>     }
>
> I'm not sure if this is the intended behavior or not.  Does anyone else
> have any thoughts on this issue?
>
> Thanks,
> Whit
>
>
>
>
>
> This e-mail message is intended only for the named recipient(s) above. It
may contain confidential information. If you are not the intended recipient you
are hereby notified that any dissemination, distribution or copying of this
e-mail and any attachment(s) is strictly prohibited. If you have received this
e-mail in error, please immediately notify the sender by replying to this e-mail
and delete the message and any attachment(s) from your system. Thank you.
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel