Hi, I try to create a vertical line in my plot, which has a xaxis comprising time formated data. This is what I tried: ---------------- y<-152833 x<-strptime(y, format="%H%M%S") abline(v=x, col="red") ---------------- for some reason, it doesn't work and no error msg is displayed... I hope someone can tell me what I do wrong, or maybe an alternative. Thanks in advance!! -- View this message in context: http://www.nabble.com/abline%28v%3D-x%29-in-plot-with-time-formated-xaxis-not-working-tp24505884p24505884.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2009-Jul-16 02:36 UTC
[R] abline(v= x) in plot with time formated xaxis not working
On Jul 15, 2009, at 5:25 PM, F!! wrote:> > Hi, > > I try to create a vertical line in my plot, which has a xaxis > comprising > time formated data. > > This is what I tried: > > ---------------- > > y<-152833 > x<-strptime(y, format="%H%M%S") > > abline(v=x, col="red")But, but, but ... where is your plot function?> > ---------------- > > for some reason, it doesn't work and no error msg is displayed... > > I hope someone can tell me what I do wrong, or maybe an alternative. > > Thanks in advance!!David Winsemius, MD Heritage Laboratories West Hartford, CT
Patrick Connolly
2009-Jul-19 05:17 UTC
[R] abline(v= x) in plot with time formated xaxis not working
Dear Fritz, (had to guess the name as well as most of the other things not given) On Wed, 15-Jul-2009 at 02:25PM -0700, F!! wrote: |> |> Hi, |> |> I try to create a vertical line in my plot, which has a xaxis comprising |> time formated data. |> |> This is what I tried: |> |> ---------------- |> |> y<-152833 |> x<-strptime(y, format="%H%M%S") |> |> abline(v=x, col="red") |> |> ---------------- |> |> for some reason, it doesn't work and no error msg is displayed... My guess is that you don't already have a plot, or if you do, your value of x is outside the range it covers. Try par()$usr and see if my guess is correct. There's no way I can tell. |> |> I hope someone can tell me what I do wrong, or maybe an alternative. If you had a reproducible example, they'd be in a better position. |> ______________________________________________ |> 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. Notice the last line? -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___ Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) ..... Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
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.