[R] How to add e.g. lines to a zoo plot?
Oliver Faulhaber
oliverfaulhaber at gmx.de
Sun Apr 22 20:05:37 CEST 2007
Hi all,
a problem I encounter again and again: I plot a zoo object using "plot"
and then want to add lines or points to this plot.
I usually circumvent this problem by adding artificial coloumns to the
zoo object before plotting, but I am sure there's a better solution.
To be specific: Assume I did
x <- as.Date(c("2002-01-01","2003-01-01","2004-01-01"))
y.zoo <- zoo(cbind(y1=c(1,2,3),y2=c(3,4,3)),order.by=x)
plot(y.zoo)
and want to add a straight line like
lines(x,c(2,2,2),col="blue")
to the first panel. How can I achieve this? Performing the "lines" does
indeed create a line, but puts it in the middle of nowhere.
Thanks in advance
Oliver
--
Oliver Faulhaber · Heckerstr. 2a · D-68723 Schwetzingen
oliverfaulhaber at gmx.de · http://www.oliver-faulhaber.de
More information about the R-help
mailing list