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) Gregory A. Graves Lead Scientist REstoration COoordination and VERification (RECOVER) Watershed Division South Florida Water Management District Phones: DESK: 561 / 682 - 2429 CELL: 561 / 719 - 8157
Ask yourself: a) whether anyone could possibly see what you are seeing with the data you have offered, and ... (Just a guess that this is the problem) b) what POSIXct dates are represented by 1:9? Would they even be in the range 2001-2009? > ddd <- as.POSIXct(strptime(c("01/01/2000", "01/02/2000"),format="%m/ %d/%Y")) > ddd [1] "2000-01-01 EST" "2000-01-02 EST" > ddd+1 [1] "2000-01-01 00:00:01 EST" "2000-01-02 00:00:01 EST" On Jun 8, 2009, at 2:59 PM, 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) >David Winsemius, MD Heritage Laboratories West Hartford, CT
The axis will use the internal representation of the dates. See R News 4/1 for more on that. On Mon, Jun 8, 2009 at 2:59 PM, Graves, Gregory<ggraves at sfwmd.gov> 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) > > > > Gregory A. Graves > Lead Scientist > REstoration COoordination and VERification (RECOVER) > Watershed Division > South Florida Water Management District > Phones: ?DESK: 561 / 682 - 2429 > ? ? ? ? ? ? CELL: ?561 / 719 - 8157 > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
After doing your plot command, type par()$usr This will give you the x and y axis ranges. Make sure that the "at" values you give are within the x-axis range. -Don At 2:59 PM -0400 6/8/09, 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) > > > >Gregory A. Graves >Lead Scientist >REstoration COoordination and VERification (RECOVER) >Watershed Division >South Florida Water Management District >Phones: DESK: 561 / 682 - 2429 > CELL: 561 / 719 - 8157 > > >______________________________________________ >R-help at r-project.org mailing list >https:// stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http:// www. R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062
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