On 2012-04-26 13:47, Andy Bunn wrote:> Hello, I'm making a simple plot using xYplot in the Hmisc library and
having problems with labeling the values on the x-axis. Using the reproducible
example below, how can I have the text (jan, feb,mar, etc.) in place of 1:12.
>
> Thanks, AB
>
>
> x<- c(seq(0,0.5,by=0.1),seq(0.5,0,by=-0.1))
> ci<- rnorm(12,0,sd=0.1)
> xupper<- x + ci
> xlower<- x - ci
> mo.fac<- c("jan", "feb", "mar",
"apr", "may", "jun", "jul",
> "aug", "sep", "oct",
"nov", "dec")
> foo<- data.frame(mo=1:12,mo.fac,x,xupper,xlower)
>
> # example 1: works but I want text (jan, feb, etc.) and not numbers on the
x axis
> xYplot(Cbind(x,xlower,xupper) ~ mo,data=foo)
Just set the 'scales=' argument, e.g.
xYplot(Cbind(x,xlower,xupper) ~ mo,data=foo,
scales = list(at = 1:12, labels = month.abb))
Peter Ehlers
>
> # example 2: doesn't work
> xYplot(Cbind(x,xlower,xupper) ~ mo.fac,data=foo)
>