[R] abline(v= x) in plot with time formated xaxis not working

F!! pech at students.uni-mainz.de
Sun Jul 19 17:33:17 CEST 2009


Sorry for the lack of the plot. It's is just a simple xy plot with xvalues
formated as shown in my post (strptime()).

Anyway, here a working example:



> 
> rm(list=ls())
> 
> x<-c(100*1500:1559, 100*1600:1659)
> x<-strptime(x, format="%H%M%S")
> y<-c(CO2$conc, CO2$conc[1:36])
> 
> plot(x, y, pch=18, type="p", ylab="yfoo", xlab="xfoo", yaxs="r")
> 
> abline(h=100, v=0, col="gray60", lty=2)
> text.xvalue<-151500
> text.xvalue<-strptime(text.xvalue, format="%H%M%S")
> text(text.xvalue, 80, "detection threshold", col="gray60", cex=0.8)
> 
> event.1<-152833
> event.1<-strptime(event.1, format="%H%M%S")
> abline(v=event.1, col="red")
> 
> 

The format for the xvalues works in the case of text positioning, but
doesn't in the case of abline. 

JimHoltman replied this topic via email with a solution:

<-as.POSIXct(strptime(y, format="%H%M%S"))


I still don't know why this second function is necessary since everything
works without it, except for the abline-thing...

Nevertheless, thanks for all the suggestions!

Fritz
-- 
View this message in context: http://www.nabble.com/abline%28v%3D-x%29-in-plot-with-time-formated-xaxis-not-working-tp24505884p24558044.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list