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

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Feb 12 19:15:45 CET 2012



On 12.02.2012 11:09, Christof Kluß wrote:
> Hi,
>
> 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?
>
> Thx
> Christof
>
>
> 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")


Works fine for me.
See
abline(v=as.Date("2011-01-27"), col="red", lty="dashed")
which is exactly on the date.

Uwe Ligges


>
> plot.png
>
>
>
>
> ______________________________________________
> 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.



More information about the R-help mailing list