0

I have a level plot with a POSIXct axis, and I'd like to adjust how the date is displayed, as well as the number of ticks. My example plot looks like this:

library(lattice)

Beg<-as.POSIXct('2015-01-01 14:00:00',tz='UTC')
End<-as.POSIXct('2015-01-10 14:00:00',tz='UTC')

x<-seq(Beg,End,by='hour')
y<-rep(1:5,10)
z<-rep(1:5,10)


levelplot(z ~ x * y)

I'd like to display the dates in a "%d-%H" format, and increase the number of ticks so we have two ticks per day (at 11 and 23 hours)

I've tried using the scales argument as listed in other examples, but am having issues with POSIXct

ByHour<-x[as.numeric(format(x,"%H")) == 11 |as.numeric(format(x,"%H")) == 23]
d<-strftime(ByHour, format="%d-%H")

levelplot(z ~ x * y, scales= list(list(x=ByHour))) #Does not work
levelplot(z ~ x * y, scales= list(list(x=d))) #Does not work
Vint
  • 413
  • 6
  • 17
  • "The other examples"? Could you be any less specific? – IRTFM Apr 06 '18 at 01:05
  • Other examples = similar questions/ answers found on this site – Vint Apr 06 '18 at 01:27
  • Well, no one can say I didn't try to give you a clue, but some people are apparently irretrievably ... I can't say it. Not politically correct. Continue on with your blithe approach to knowledge. – IRTFM Apr 06 '18 at 03:34

0 Answers0