[R] no x label using axis.Date

MKN matthewnewland at gauge.com.au
Fri Jun 13 04:47:04 CEST 2014


I have tried multiple different methods to figure out how to get a date axis
of my preference (start date of each month). Any assistance would be
appreciated.
The below section is not producing a date axis:

plot(totaldays$totaldays,totaldays$y,type="n",ylim=c(0,Emax),xaxt="n")
*xlabels<-(strptime(totaldays$totaldays,"%Y-%m-%d",tz=""))
xlabels<-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format="%b-%Y")*

The above section is used in the following plot:

par(mfrow=c(4,1))
par(mar=c(0.8,0,0,0))
par(oma=c(2,4.5,3,2))

plot(totaldays$totaldays,totaldays$y,type="n",ylim=c(0,Dmax),xaxt="n")
points(D$date,D$TSP,col=Dcol,type="p",pch=16,lwd=2,xaxt="n")
text(mdate,Dmax-20,labels="DM1'",cex=1)
legend("topright",pch=16,cex=0.8,col=colLegend,
       legend=ALegend)
abline(h=Target,col="red",lwd=2)

plot(totaldays$totaldays,totaldays$y,type="n",ylim=c(0,Bmax),xaxt="n")
points(B$date,B$TSP,col=Bcol,type="p",pch=16,lwd=2,xaxt="n")
text(mdate,Bmax-20,labels="DM2",cex=1)
abline(h=Target,col="red",lwd=2)

plot(totaldays$totaldays,totaldays$y,type="n",ylim=c(0,Amax),xaxt="n")
points(A$date,A$TSP,col=Acol,type="p",pch=16,lwd=2,xaxt="n")
text(mdate,Amax-20,labels="DM3",cex=1)
abline(h=Target,col="red",lwd=2)

plot(totaldays$totaldays,totaldays$y,type="n",ylim=c(0,Emax),xaxt="n")
*xlabels<-(strptime(totaldays$totaldays,"%Y-%m-%d",tz=""))
xlabels<-xlabels[xlabels$mday==1]
axis.Date(1,at=xlabels,format="%b-%Y")*
points(E$date,E$TSP,col=Ecol,type="p",pch=16,lwd=2)
text(mdate,Emax-20,labels="DM4'",cex=1)
abline(h=Target,col="red",lwd=2)

title(main=Amain, ylab=Labely,
      outer=TRUE,cex.lab=1, cex.main=1.5)

Below is an excerpt of the total days data:

	totaldays	        y
1	2013-11-01	1
2	2013-11-02	1
3	2013-11-03	1
4	2013-11-04	1
5	2013-11-05	1
6	2013-11-06	1
7	2013-11-07	1
8	2013-11-08	1
9	2013-11-09	1
10	2013-11-10	1




--
View this message in context: http://r.789695.n4.nabble.com/no-x-label-using-axis-Date-tp4692034.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list