[R-SIG-Finance] plotting zoo objects
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Aug 4 12:07:42 CEST 2006
Interpreting the problem as given a 1d zoo object z, plot its
data against 1, 2, 3, ... rather than the times
and then use some custom labelling of the axis:
# test data -- z has 5 values, a break of 2, 5 values, etc.
z <- zoo(c(1:5, 8:12, 15:19), c(1:5, 8:12, 15:19))
plot(coredata(z), xaxt = "n", type = "l")
idx <- seq(1, length(z), 5)
axis(1, idx, time(z)[idx]) # custom label axis with every 5th value
The above does not actually use plot.zoo since we are plotting
the data of zoo rather than a zoo object. If for some reason you
need to use plot.zoo change it (only the plot statement has changed)
to the following which defines a new zoo object with sequence
numbers as times:
z <- zoo(c(1:5, 8:12, 15:19), c(1:5, 8:12, 15:19))
plot(zoo(coredata(z)), xaxt = "n", type = "l")
idx <- seq(1, length(z), 5)
axis(1, idx, time(z)[idx])
On 8/4/06, Øyvind Foshaug <oyvfos at yahoo.no> wrote:
> Hi all,
> I would like to plot a zoo object, removing non-trading days, and adjust the tick resolution and the ticklabels. Is that possible?
> Oyvind
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>
More information about the R-SIG-Finance
mailing list