[R] plotting dates, incorrectly scaled x-axis?

Christof Kluß ckluss at email.uni-kiel.de
Sun Feb 12 11:09:42 CET 2012


I want to plot with axis.Date(), but something is scaled incorrectly.
The red vertical line in is put on a totally wrong position. (sample below)

Do you have an idea what I'm doing wrong?


x11(width=30, height=20)

x<-seq(as.Date("2010-02-27"), as.Date("2011-03-28"),"month")
y <- seq(0,100,length=length(x))

plot(y ~ x, type="o", tck=1, xaxt="n")

axis.Date(1, at=x, labels=format(x,"%b\n%Y"), padj=0.5)

abline(v=as.Date("2011-01-01"), col="red", lty="dashed")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot.png
Type: image/png
Size: 3933 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120212/35a891e6/attachment.png>

More information about the R-help mailing list