Re: [R] date Axes and formats in lattice plots

From: Deepayan Sarkar <deepayan_at_stat.wisc.edu>
Date: Mon 05 Jul 2004 - 12:16:15 EST

On Sunday 04 July 2004 21:02, Toby.Patterson@csiro.au wrote:
> All,
>
> I have some data of animal movements that I'm plotting using xyplot()
> from lattice. I want to have the date (class POSIXct object) on the
> Y-axis and the animals longitude on X-axis. Eg.
>
> xyplot(date ~ longitude, groups = animal, data = my.data)
>
> with data like:
>
> animal ptt year month day lon date
> 125 03P0014 13273 2003 7 10 150.38 2003-07-10 14:03:48
> 126 03P0192 20890 2003 7 10 151.13 2003-07-10 14:00:47
> 127 03P0197 30466 2003 7 10 150.74 2003-07-10 14:02:21
> ...etc
>
> It all works fine except for the format of the dates that gets
> displayed.
>
> I am not sure what I need to change within the lattice frame work to
> get a specific date format (eg. "%Y-%-m-%d"). Does anyone have any
> tips or, even better, some example code that they could pass on?

For R 1.9.0 and above, you should be able to do this with

xyplot(date ~ longitude, groups = animal, data = my.data,

       scales = list(y = list(format = "%Y-%-m-%d")))

Deepayan



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jul 05 12:19:22 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:41 EST