[R] Plot.xts - how to change the x-axis labels to show weekly labels.

Joshua Ulrich josh.m.ulrich at gmail.com
Sat Jul 30 18:08:34 CEST 2011


Hi Eduardo,

I'm not too familiar with plot.xts, but this answers 2/3 of your requests.
R> plot(x, major.ticks="weeks", major.format="%b %d")

plot.zoo is quite a bit more flexible and has a lot of examples in
?plot.zoo.  Combining plot.zoo with endpoints should be able to give
you what you want.

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Sat, Jul 30, 2011 at 9:10 AM, Eduardo M. A. M.Mendes
<emammendes at gmail.com> wrote:
> Dear R-users
>
>
>
> I am new to R and struggling not to bother the list with silly questions.
>
>
>
> I read the documentation on xts and searched for some examples over the
> internet on how to use plot.xts.
>
>
>
> The xts object is as follows
>
>
>
> dataxts : An 'xts' object from 2010-06-27 to 2010-08-05 containing:
>
>  Data: num [1:56161, 1:14] 74 74.2 74.2 74.1 73.9 ...
>
>  Indexed by objects of class: [POSIXct,POSIXt] TZ:
>
>  xts Attributes:
>
>  NULL
>
>
>
> The time index goes from 2010-06-27 to 2010-08-05 hourly, that is, there are
> 56151 time stamps.  If I issue plot.xts(dataxts[,1]) a graphics window comes
> out with the following x labels:
>
>
>
> Jun 27 00:00, Jul 11 21:00, Jul 25 21:00, Aug 05  00:00
>
>
>
> I could not figure out how to change the number of ticks so that the time
> stamps (major ticks) are shown weekly and the minor ticks daily.  Besides, I
> wonder whether the labels could be show as follows:
>
>
>
> Jun 27       Jul 11   Jul 25  Aug 05 (just as example)
>
> 00:00         21:00   21:00  00:00
>
>
>
> Thanks for your help and patience.
>
>
>
> Cheers
>
>
>
> Ed
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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