[R] How to show complete time values in a plot x axis

Duncan Murdoch murdoch at stats.uwo.ca
Fri Sep 19 15:24:04 CEST 2008


On 9/19/2008 9:14 AM, Sébastien Durand wrote:
> Dear Yihui,
> 
> The resulting plot produced by dotchart is not what I wish for!
> I need to produce a time axis that is consequent to the time values.
> When dotchart is used, time values are simply considered as labels.
> What I wish for is a way to produce a numerical time axis that really 
> takes into account the given time values. With plot I have been able to 
> do so, the only issue is the labelling.
> I wish to represent the complete time on the axis ticks...

Ask plot not to produce an axis, then construct the labels yourself and 
add them.  The axis.POSIXct() function will be helpful in this.

Duncan Murdoch

> 
> Cheers
> 
> Sébastien Durand
> CIDCO
> 
> Yihui Xie a écrit :
>> Hi, I'd suggest you use dotchart() instead of plot(). I believe this
>> is what you expected:
>>
>> dotchart(value, time)
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie <xieyihui at gmail.com>
>> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
>> Mobile: +86-15810805877
>> Homepage: http://www.yihui.name
>> School of Statistics, Room 1037, Mingde Main Building,
>> Renmin University of China, Beijing, 100872, China
>>
>>
>>
>> On Fri, Sep 19, 2008 at 3:10 AM, Sébastien Durand
>> <sebastien.durand at cidco.ca> wrote:
>>   
>>> Hello,
>>>
>>> I have the following data and I try to properly
>>> import it in R and plot the 4th column relative to time
>>>
>>>   1   2008-249 17:44:17.973    -2.27  00000000: Accepted
>>>   2   2008-249 17:44:18.014    -2.28  00000000: Accepted
>>>   3   2008-249 17:44:18.064    -2.29  00000000: Accepted
>>>   4   2008-249 17:44:18.123    -2.29  00000000: Accepted
>>>   5   2008-249 17:44:18.174    -2.29  00000000: Accepted
>>>   6   2008-249 17:44:18.225    -2.29  00000000: Accepted
>>>   7   2008-249 17:44:18.274    -2.28  00000000: Accepted
>>>   8   2008-249 17:44:18.325    -2.28  00000000: Accepted
>>>   9   2008-249 17:44:18.375    -2.28  00000000: Accepted
>>>  10   2008-249 17:44:18.424    -2.27  00000000: Accepted
>>>  11   2008-249 17:44:18.475    -2.26  00000000: Accepted
>>>  12   2008-249 17:44:18.514    -2.24  00000000: Accepted
>>>  13   2008-249 17:44:18.565    -2.23  00000000: Accepted
>>>  14   2008-249 17:44:18.615    -2.20  00000000: Accepted
>>>  15   2008-249 17:44:18.674    -2.17  00000000: Accepted
>>>  16   2008-249 17:44:18.725    -2.15  00000000: Accepted
>>>  17   2008-249 17:44:18.774    -2.12  00000000: Accepted
>>>  18   2008-249 17:44:18.825    -2.09  00000000: Accepted
>>>  19   2008-249 17:44:18.875    -2.06  00000000: Accepted
>>>  20   2008-249 17:44:18.925    -2.03  00000000: Accepted
>>>  21   2008-249 17:44:18.975    -2.00  00000000: Accepted
>>>  22   2008-249 17:44:19.026    -1.97  00000000: Accepted
>>>  23   2008-249 17:44:19.055    -1.95  00000000: Accepted
>>>
>>> #I copy the previous data then in R dat=readLines("clipboard")
>>> options(digits.secs=6)
>>> tmp=unlist(lapply(dat,function(x){unlist(strsplit(x,"\\
>>> +",perl=TRUE))[3:5]}))
>>> tmp=matrix(tmp,ncol=3,byrow=TRUE)
>>> tmp=cbind(paste(tmp[,1],tmp[,2]),tmp[,3])
>>> time=strptime(tmp[,1], format="%Y-%j %H:%M:%OS")
>>> value=as.numeric(tmp[,2])
>>> plot(time,value)
>>> #How can I show in the x axis the complete time values including the
>>> decimals.
>>>
>>> Thanks a lot
>>>
>>> N.B.: I am running the lastest version of R and using it under Windows XP
>>>
>>> S.
>>>
>>> ______________________________________________
>>> 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.
>>>
>>>     
>>
>>
> 
> ______________________________________________
> 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