[R] How can I shade the background area of a zoo time series object between specific dates?

Gabor Grothendieck ggrothendieck at gmail.com
Thu Jun 19 17:42:26 CEST 2008


See ?rect

library(zoo)
d1 <- as.Date("2007-04-12")
d2 <- as.Date("2008-05-14")
plot(SP500, type = "n")
rect(d1, par("usr")[3], d2, par("usr")[4], col = "red", border = 0)
lines(SP500)

Also, there is an example using the lattice/grid-based xyplot.zoo in ?xyplot.zoo

On Thu, Jun 19, 2008 at 10:48 AM, Vorlow Constantinos
<CVorlow at eurobank.gr> wrote:
> Dear list members,
>
> How can I shade the background area of a zoo time series object between
> specific dates?
>
> eg.
>
>    library(tseries)
>    library(zoo)
>    SP500<-get.hist.quote("^GSPC", start = "1990-01-01", quote =
> "Close")
>    plot(SP500)
>
> How can I produce the same plot but with a (say) red background between
>
>    2007-04-12
>
> and
>
>    2008-05-14
>
> ?
>
> Many thanks in advance...
>
> Costas
>
>
> P Think before you print.
>
> Disclaimer:
> This e-mail is confidential. If you are not the intended recipient, you should not copy it, re-transmit it, use it or disclose its contents, but should return it to the sender immediately and delete the copy from your system.
> EFG Eurobank Ergasias S.A. is not responsible for, nor endorses, any opinion, recommendation, conclusion, solicitation, offer or agreement or any information contained in this communication.
> EFG Eurobank Ergasias S.A. cannot accept any responsibility for the accuracy or completeness of this message as it has been transmitted over a public network. If you suspect that the message may have been intercepted or amended, please call the sender.
>
>
>        [[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