Skip to content
Prev 364784 / 398500 Next

Adjusting axis labels on lattice xyplot

The structure( .. ) call would need to be sourced:
List of 2
 $ value  :'data.frame':	341 obs. of  3 variables:
  ..$ station: Factor w/ 6 levels "0.3E","0.6W",..: 1 1 1 1 1 1 1 1 1 1 ...
  ..$ date   : Factor w/ 62 levels "2013-12-01","2013-12-02",..: 32 33 34 35 36 37 38 39 40 41 ...
  ..$ amount : Factor w/ 48 levels "","0.00","0.01",..: 1 1 3 2 2 2 12 18 34 14 ...
 $ visible: logi TRUE

When you do that you can see the only the first item in the length2 list is likely to be useful:
'data.frame':	341 obs. of  3 variables:
 $ station: Factor w/ 6 levels "0.3E","0.6W",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ date   : Factor w/ 62 levels "2013-12-01","2013-12-02",..: 32 33 34 35 36 37 38 39 40 41 ...
 $ amount : Factor w/ 48 levels "","0.00","0.01",..: 1 1 3 2 2 2 12 18 34 14 ...

#So re-assign#

rain <- rain[[1]]

And the date column is a factor. Fortunately the as.Date.factor function doesn't need as.chaacter anymore:

rain$date=as.Date(rain$date)
The place on the ?xyplot help page to look is in the section on `scales`. There's no difficulty using 'rot' as long as it is in the correct place which in this instance is `x` sublist of the `scales` list

xyplot(amount ~ date | station, data=rain, main="Weather Stations",
    xlab="Date", ylab="Amount (inches)", pch=16, col=132, 
    scales=list(y=list(at=0:4), 
                x=list(at=seq(min(rain$date), max(rain$date), by='week'), rot=90) )
      )
David Winsemius
Alameda, CA, USA