[R] increase number of ticks on x axis of dates
Jim Lemon
jim at bitwrit.com.au
Tue Jun 9 12:18:44 CEST 2009
Graves, Gregory wrote:
> My x axis is a series of daily dates (e.g., 01/01/2000, 01/02/2000,
> etc.) from 2000 to end of 2008. The default only gives me 4 ticks. I
> want more. Why doesn't this work?
>
> sdate<-as.POSIXct(strptime(date,format="%m/%d/%Y"))
>
> plot(ppt~sdate,type="l",ylim=c(0,47),col=1,lwd=1,pch=16,ylab="Salinity,
> psu",xlab="Year",las=1,main="Duck Key Salinity",xaxt="n")
>
> year.text=c("2001","2002","2003","2004", "2005", "2006", "2007","2008",
> "2009")
>
> axis(1, at=c(1:9),labels=year.text)
>
Hi Gregory,
Try this:
library(plotrix)
staxlab(1,at=1:9,labels=year.text)
If the labels are still too crowded, add a bit of margin and try this:
par(mar=c(6,4,4,2))
staxlab(1,at=1:9,labels=year.text,nlines=3)
Jim
More information about the R-help
mailing list