Skip to content

date axes and formats in levelplot

2 messages · Toby.Patterson@csiro.au, Deepayan Sarkar

#
Hi all (and particularly Deepayan), 

A while back Deepayan helped me with the query in the text below (thanks
again). Specifically it was about changing the way that dates plotted on
the axes of lattice plots. 

While this works using xyplot, everything comes apart when I use
levelplot. The axis labels on the date axis are shown as the integer
representation of the date (number of seconds since the origin I
assume). I guess that the POSIX dates are getting coerced into numeric
objects somewhere along the way and that there is no easy fix for this. 

I would be really grateful if there is a work around that would allow me
to plot recognizable dates. Any suggestions?

Cheers 
Toby  

-----Original Message-----
From: Deepayan Sarkar [mailto:deepayan at stat.wisc.edu] 
Sent: Monday, July 05, 2004 12:16 PM
To: r-help at stat.math.ethz.ch
Cc: Patterson, Toby (Marine, Hobart)
Subject: Re: [R] date Axes and formats in lattice plots
On Sunday 04 July 2004 21:02, Toby.Patterson at csiro.au wrote:
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
#
On Tuesday 10 August 2004 01:34, Toby.Patterson at csiro.au wrote:
You are right. At first glance, it appears that I have been negligent in 
properly updating the default prepanel function for levelplot to handle 
DateTime objects. For now, you could use xyplot's default instead: 

levelplot(z ~ x * y, 
          prepanel = lattice:::prepanel.default.xyplot)

Add a 'scales = list(axs = "i")' to get a better looking result (with 
the bordering rectangles partially clipped).

Deepayan