Java Mailing List Archive

http://www.r-help.com/

Home » Home (12/2007) » R Help for Statistical Computing »

Re: [R] axis command and excel time format

Gabor Grothendieck

2006-11-08

Replies:

Your code plots x which has nothing to do with xt.

On 11/8/06, Carmen Meier <carmei3@(protected):
> Yes this one works, but (sorry) in the OP there was a plot without data
> to define the range
> So I tried to use your working suggestion in that manner:
>
> library(zoo)
> library(chron)
> time <-
> c("2:25:00","2:26:00","2:27:00","2:28:00","2:29:00","2:30:00","2:31:00",
>
> "2:32:00","2:33:00","2:34:00","2:35:00","2:36:00","2:37:00","2:38:00",
>
> "2:39:00","2:40:00","2:41:00","2:42:00","2:43:00","2:44:00","2:45:00",
>
> "2:46:00","2:47:00","2:48:00","2:49:00","2:50:00","2:51:00","2:52:00",
>
> "2:53:00","2:54:00","2:55:00","2:56:00","2:57:00","2:58:00","2:59:00",
>
> "3:00:00","3:01:00","3:02:00","3:03:00","3:04:00","3:05:00","3:06:00",
>
> "3:07:00","3:08:00","3:09:00","3:10:00","3:11:00","3:12:00","3:13:00",
>       "3:14:00")
>   min_time <- min(times(time))
>   max_time <- max(times(time))
>
>   duration <- max_time-min_time
>    h <- hours(duration) # not nessesary here
>   m <- minutes(duration)
>   par(cex=1.2,lwd=1)
>   range(x <- c(0,m)) #50 minutes
>   range(y <- c(0,10))
>   plot(x,y, type="n",adj=0, asp=0, xlab="",
> ylab="",axes=FALSE,font.axis=2)
> #   axis(1, 0:m,font=2) # works fine but not with times
>
> #---------- your suggestion --------
> mn <- times(min_time)
> mx <- times(max_time)
> n <- 5
>
> xt <- times(seq(mn, mx, length = n))
>
> xt <- times(unique(sub("..$", "00", xt)))
>
> axis(1, xt, sub(":00$", "", xt)) # works only with plot data before
> #----------------------
>   axis(2, 0:10,font=2)
>   box()
>
>
> Maybe you could explain the difference
>
> Best regards Carmen
>

______________________________________________
R-help@(protected)
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.
©2008 r-help.com - Jax Systems, LLC, U.S.A.