Re: [R] axis command and excel time format
Carmen, Gabor has already given you the detail you ask for, but might try the following plot to see what is going wrong: plot(times(tt), x, type='l') This does not give you the EXACT control of the axis you asked for, but this simple plot command gives you a fairly nice result. It illustrates that your code is failing becasue you are plotting x against the index of x rather than plotting x against time. At least this is what I think the misunderstanding is. Thank you Robert, this is nearly what I need, but my problem is that I need an empty window with axes. I am able to build this with any data but not with the time axis. I need for a special issue only horizontal lines with different colors and arrows, which will be inserted from a function. Maybe you could explain me what's the difference between 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) y - c(0,10) plot(times(time), y, type='n') - error in xy.coords(x, y, xlabel, ylabel, log) :'x' and 'y' lengths differ - the error is only with type='n' and not with type='l' and the example without errors 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) y - c(0,10) plot(times(time), y, type='l') It is not the type='n' every other combination of data types which i tried was working with the no plot option y - c(0,10) z - c(0,10) plot(z, y, type='n') Carmen __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
You should look at ?plot.default ?times You need to supply an x vector (time) along with a y value vector of the same length. Your error message tells you that you vectors were not of equal length. You are repeatedly supplying different length vectors. times() takes a text vector and translates it into an object of class time. Try the following to see if it unscrambles things for you. You can go on to suppress axis labels, etc. by using other arguments as necessary . xrange=times(c(2:25:00,3:14:00)) yrange=c(0,10) plot(xrange,yrange,type='n') - Original Message - From: Carmen Meier [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, November 10, 2006 5:13 AM Subject: Re: [R] axis command and excel time format Carmen, Gabor has already given you the detail you ask for, but might try the following plot to see what is going wrong: plot(times(tt), x, type='l') This does not give you the EXACT control of the axis you asked for, but this simple plot command gives you a fairly nice result. It illustrates that your code is failing becasue you are plotting x against the index of x rather than plotting x against time. At least this is what I think the misunderstanding is. Thank you Robert, this is nearly what I need, but my problem is that I need an empty window with axes. I am able to build this with any data but not with the time axis. I need for a special issue only horizontal lines with different colors and arrows, which will be inserted from a function. Maybe you could explain me what's the difference between 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) y - c(0,10) plot(times(time), y, type='n') - error in xy.coords(x, y, xlabel, ylabel, log) :'x' and 'y' lengths differ - the error is only with type='n' and not with type='l' and the example without errors 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) y - c(0,10) plot(times(time), y, type='l') It is not the type='n' every other combination of data types which i tried was working with the no plot option y - c(0,10) z - c(0,10) plot(z, y, type='n') Carmen __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
You are using two different x's and one has nothing to do with the other. All of your examples are simply internally inconsistent so there is no reason to think they would work. On 11/9/06, Carmen Meier [EMAIL PROTECTED] wrote: Gabor Grothendieck schrieb: Please provide a complete self contained example. I can't follow the partial code below; however, its likely you are plotting one thing and creating axes using another so there is no reason it should come out right. You are right .. seems to be that it was too late at night ... But I tried the right code and sent the wrong one ... the problem is still there 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 - 12 x - times(seq(mn, mx, length = n)) x - times(unique(sub(..$, 00, x))) axis(1, x, sub(:00$, , x)) # works only with plot data before #-- axis(2, 0:10,font=2) box() Best regards Carmen __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Try this: plot(z, xaxt = n) xt - paste(23, seq(5, 50, 5), sep = :) axis(1, times(paste(xt, 0, sep = :)), xt) On 11/8/06, Carmen Meier [EMAIL PROTECTED] wrote: Hi to all, I have some problems to get the times-scale to the x-axis the times are coming from an excel sheet f. e [1] 0:01:00 0:02:00 0:03:00 0:04:00 0:05:00 0:06:00 0:07:00 [8] 0:08:00 0:09:00 0:10:00 0:11:00 0:12:00 0:13:00 0:14:00 [15] 0:15:00 0:16:00 0:17:00 0:18:00 0:19:00 0:20:00 0:21:00 [22] 0:22:00 0:23:00 0:24:00 0:25:00 0:26:00 0:27:00 0:28:00 [29] 0:29:00 0:30:00 0:31:00 0:32:00 0:33:00 0:34:00 0:35:00 [36] 0:36:00 0:37:00 0:38:00 0:39:00 0:40:00 0:41:00 0:42:00 [43] 0:43:00 0:44:00 0:45:00 0:46:00 0:47:00 0:48:00 0:49:00 [50] 0:50:00 I found the solution from tread http://finzi.psych.upenn.edu/R/Rhelp02a/archive/71234.html with an very good result: / # test data / / tt - c(23:05:02, 23:10:02, 23:15:03, 23:20:03, 23:25:03, / / 23:30:03, 23:35:03, 23:40:03, 23:45:04, 23:50:04, 23:55:03, / / 23:55:03) / / x - c(0.575764, 0.738379, 0.567414, 0.663436, 0.599834, 0.679571, / / 0.88141, 0.868848, 0.969271, 0.878968, 0.990972, 0.990972) / / / / library(zoo) / / library(chron) / / z - zoo(x, times(tt)) / / plot(z) / / / but I am unable to use the axis command for that issue: how could I change the axis(1, xaxp=c(0,50,5),font=2) that I will get a changeable amount of x-axis entries with a time format hr:min par(cex=1.2,lwd=1) range(x - c(0,50)) range(y - c(0,10)) plot(x,y, type=n,adj=0, asp=0, xlab=, ylab=,axes=FALSE,font.axis=2) axis(1, xaxp=c(0,50,5),font=2) axis(2, 0:10,font=2) box() Thank`s in advance Carmen __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Thank you for your reply Gabor, sure, the manually written axis works fine in any configuration. but I would prefer an automatic input. That means that I would like to use the datafield[1] for the minimum time and the datafield[max] (means the last one) for the maximum time. divided into x steps.The datafiled size could reach more than 7000 sec. With regards Carmen Gabor Grothendieck schrieb: Try this: plot(z, xaxt = n) xt - paste(23, seq(5, 50, 5), sep = :) axis(1, times(paste(xt, 0, sep = :)), xt) I have some problems to get the times-scale to the x-axis the times are coming from an excel sheet f. e [1] 0:01:00 0:02:00 0:03:00 0:04:00 0:05:00 0:06:00 0:07:00 [8] 0:08:00 0:09:00 0:10:00 0:11:00 0:12:00 0:13:00 0:14:00 [15] 0:15:00 0:16:00 0:17:00 0:18:00 0:19:00 0:20:00 0:21:00 [22] 0:22:00 0:23:00 0:24:00 0:25:00 0:26:00 0:27:00 0:28:00 [29] 0:29:00 0:30:00 0:31:00 0:32:00 0:33:00 0:34:00 0:35:00 [36] 0:36:00 0:37:00 0:38:00 0:39:00 0:40:00 0:41:00 0:42:00 [43] 0:43:00 0:44:00 0:45:00 0:46:00 0:47:00 0:48:00 0:49:00 [50] 0:50:00 __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Is the problem how to produce an axis with a given minimum tick, maximum tick and given number of ticks? In that case try this (if not explain further): # input data # z is from original example mn - times(23:00:00) mx - times(23:55:00) n - 12 xt - times(seq(mn, mx, length = n)) plot(z, xaxt = n) axis(1, xt, sub(:00$, , xt)) If this is not what you want please explain further. On 11/8/06, Carmen Meier [EMAIL PROTECTED] wrote: Thank you for your reply Gabor, sure, the manually written axis works fine in any configuration. but I would prefer an automatic input. That means that I would like to use the datafield[1] for the minimum time and the datafield[max] (means the last one) for the maximum time. divided into x steps.The datafiled size could reach more than 7000 sec. With regards Carmen Gabor Grothendieck schrieb: Try this: plot(z, xaxt = n) xt - paste(23, seq(5, 50, 5), sep = :) axis(1, times(paste(xt, 0, sep = :)), xt) I have some problems to get the times-scale to the x-axis the times are coming from an excel sheet f. e [1] 0:01:00 0:02:00 0:03:00 0:04:00 0:05:00 0:06:00 0:07:00 [8] 0:08:00 0:09:00 0:10:00 0:11:00 0:12:00 0:13:00 0:14:00 [15] 0:15:00 0:16:00 0:17:00 0:18:00 0:19:00 0:20:00 0:21:00 [22] 0:22:00 0:23:00 0:24:00 0:25:00 0:26:00 0:27:00 0:28:00 [29] 0:29:00 0:30:00 0:31:00 0:32:00 0:33:00 0:34:00 0:35:00 [36] 0:36:00 0:37:00 0:38:00 0:39:00 0:40:00 0:41:00 0:42:00 [43] 0:43:00 0:44:00 0:45:00 0:46:00 0:47:00 0:48:00 0:49:00 [50] 0:50:00 __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: Is the problem how to produce an axis with a given minimum tick, maximum tick and given number of ticks? In that case try this yes but ... ;-) I started with an plain R gui library(zoo) library(chron) # input data # z is from original example mn - times(23:00:00) mx - times(23:55:00) n - 12 z -(1:50) xt - times(seq(mn, mx, length = n)) plot(z, xaxt = n) axis(1, xt, sub(:00$, , xt)) The result is an X-axes with 23:00 at the left side nothing else at the x-axis That`s just the same problem as I got with further trials of my own and a minor problem will be sub(:00$, , xt)) if times(seq(mn, mx, length = n)) will not result xx:yy:00 values only (f.e n=17) Regards Carmen __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
My understanding is that the main point of your post was how to get times on the X axis. hopefully at this point its clear how to do that and you can come up with some algorithm to put whatever points you want on. Here is a slight generalization although you will likely have to generalize it further. library(zoo) library(chron) tt - c(23:05:02, 23:10:02, 23:15:03, 23:20:03, 23:25:03, +23:30:03, 23:35:03, 23:40:03, 23:45:04, 23:50:04, 23:55:03, +23:55:03) x - c(0.575764, 0.738379, 0.567414, 0.663436, 0.599834, 0.679571, +0.88141, 0.868848, 0.969271, 0.878968, 0.990972, 0.990972) z - zoo(x, times(tt)) mn - times(23:00:00) mx - times(23:55:00) n - 12 xt - times(seq(mn, mx, length = n)) xt - times(unique(sub(..$, 00, xt))) plot(z, xaxt = n) axis(1, xt, sub(:00$, , xt)) R.version.string [1] R version 2.4.0 Patched (2006-10-24 r39722) packageDescription(zoo)$Version [1] 1.2-1 packageDescription(chron)$Version [1] 2.3-9 On 11/8/06, Carmen Meier [EMAIL PROTECTED] wrote: Gabor Grothendieck schrieb: Is the problem how to produce an axis with a given minimum tick, maximum tick and given number of ticks? In that case try this yes but ... ;-) I started with an plain R gui library(zoo) library(chron) # input data # z is from original example mn - times(23:00:00) mx - times(23:55:00) n - 12 z -(1:50) xt - times(seq(mn, mx, length = n)) plot(z, xaxt = n) axis(1, xt, sub(:00$, , xt)) The result is an X-axes with 23:00 at the left side nothing else at the x-axis Not for me. It gives ticks all along the x axis for me. I have placed the entire self contained code above just to be sure. That`s just the same problem as I got with further trials of my own and a minor problem will be sub(:00$, , xt)) if times(seq(mn, mx, length = n)) will not result xx:yy:00 values only (f.e n=17) Regards Carmen __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: My understanding is that the main point of your post was how to get times on the X axis. hopefully at this point its clear how to do that and you can come up with some algorithm to put whatever points you want on. That´s right thank you Here is a slight generalization although you will likely have to generalize it further. . this code works fine - just I was looking for library(zoo) library(chron) tt - c(23:05:02, 23:10:02, 23:15:03, 23:20:03, 23:25:03, +23:30:03, 23:35:03, 23:40:03, 23:45:04, 23:50:04, 23:55:03, +23:55:03) x - c(0.575764, 0.738379, 0.567414, 0.663436, 0.599834, 0.679571, +0.88141, 0.868848, 0.969271, 0.878968, 0.990972, 0.990972) z - zoo(x, times(tt)) Gabor Grothendieck schrieb: Is the problem how to produce an axis with a given minimum tick, maximum tick and given number of ticks? In that case try this yes but ... ;-) I started with an plain R gui library(zoo) library(chron) # input data # z is from original example mn - times(23:00:00) mx - times(23:55:00) n - 12 z -(1:50) xt - times(seq(mn, mx, length = n)) plot(z, xaxt = n) axis(1, xt, sub(:00$, , xt)) The result is an X-axes with 23:00 at the left side nothing else at the x-axis Not for me. It gives ticks all along the x axis for me. I have placed the entire self contained code above just to be sure. This one (above) does not work R.version.string [1] R version 2.4.0 (2006-10-03) packageDescription(chron)$Version [1] 2.3-9 Regards Carmen __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
You indicated that one of the solutions did not work for you but I am not clear which one you were referring to. To avoid confusion I have deleted all my and your comments except for the following which works for me if I paste it into a fresh session using Edit | Paste commands only menu in Windows XP: library(zoo) library(chron) tt - c(23:05:02, 23:10:02, 23:15:03, 23:20:03, 23:25:03, +23:30:03, 23:35:03, 23:40:03, 23:45:04, 23:50:04, 23:55:03, +23:55:03) x - c(0.575764, 0.738379, 0.567414, 0.663436, 0.599834, 0.679571, +0.88141, 0.868848, 0.969271, 0.878968, 0.990972, 0.990972) z - zoo(x, times(tt)) mn - times(23:00:00) mx - times(23:55:00) n - 12 xt - times(seq(mn, mx, length = n)) xt - times(unique(sub(..$, 00, xt))) plot(z, xaxt = n) axis(1, xt, sub(:00$, , xt)) R.version.string [1] R version 2.4.0 Patched (2006-10-24 r39722) packageDescription(zoo)$Version [1] 1.2-1 packageDescription(chron)$Version [1] 2.3-9 __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
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@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Your code plots x which has nothing to do with xt. On 11/8/06, Carmen Meier [EMAIL PROTECTED] wrote: 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@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: Your code plots x which has nothing to do with xt. The same result if you change xt to x: 02:25 at the origin nothing else - I do not know why #-- your suggestion mn - times(min_time) mx - times(max_time) n - 12 t - times(seq(mn, mx, length = n)) t - times(unique(sub(..$, 00, t))) axis(1, x, sub(:00$, , x)) # works only with plot data before Regards Carmen __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Please provide a complete self contained example. I can't follow the partial code below; however, its likely you are plotting one thing and creating axes using another so there is no reason it should come out right. On 11/8/06, Carmen Meier [EMAIL PROTECTED] wrote: Gabor Grothendieck schrieb: Your code plots x which has nothing to do with xt. The same result if you change xt to x: 02:25 at the origin nothing else - I do not know why #-- your suggestion mn - times(min_time) mx - times(max_time) n - 12 t - times(seq(mn, mx, length = n)) t - times(unique(sub(..$, 00, t))) axis(1, x, sub(:00$, , x)) # works only with plot data before Regards Carmen __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Carmen, Gabor has already given you the detail you ask for, but might try the following plot to see what is going wrong: plot(times(tt), x, type='l') This does not give you the EXACT control of the axis you asked for, but this simple plot command gives you a fairly nice result. It illustrates that your code is failing becasue you are plotting x against the index of x rather than plotting x against time. At least this is what I think the misunderstanding is. HTH Please provide a complete self contained example. I can't follow the partial code below; however, its likely you are plotting one thing and creating axes using another so there is no reason it should come out right. On 11/8/06, Carmen Meier [EMAIL PROTECTED] wrote: Gabor Grothendieck schrieb: Your code plots x which has nothing to do with xt. The same result if you change xt to x: 02:25 at the origin nothing else - I do not know why #-- your suggestion mn - times(min_time) mx - times(max_time) n - 12 t - times(seq(mn, mx, length = n)) t - times(unique(sub(..$, 00, t))) axis(1, x, sub(:00$, , x)) # works only with plot data before Regards Carmen __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] axis command and excel time format
Gabor Grothendieck schrieb: Please provide a complete self contained example. I can't follow the partial code below; however, its likely you are plotting one thing and creating axes using another so there is no reason it should come out right. You are right .. seems to be that it was too late at night ... But I tried the right code and sent the wrong one ... the problem is still there 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 - 12 x - times(seq(mn, mx, length = n)) x - times(unique(sub(..$, 00, x))) axis(1, x, sub(:00$, , x)) # works only with plot data before #-- axis(2, 0:10,font=2) box() Best regards Carmen __ R-help@stat.math.ethz.ch 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.