[R] legend/text in time series plot
Hiroyuki Kawakatsu
hkawakat at shako.sk.tsukuba.ac.jp
Sun May 6 09:19:00 CEST 2001
hi,
i need help on placing legend/text in a time series plot. here is what
i am doing (i am using rw1022 on windoze 2000):
#read data file
gdpn <- scan("jngdpsa.dat", list(year=0, qtr=0, gdp=0));
gdpr <- scan("jrgdpsa.dat", list(year=0, qtr=0, gdp=0));
#convert to time series object
gdpn <- ts(gdpn$gdp, frequency=4, start=c(1955,2));
gdpr <- ts(gdpr$gdp, frequency=4, start=c(1955,2));
#plot two gdp time series in one graph
postscript("fig2-1j.eps", horizontal=FALSE, onefile=FALSE, height=5, width=6);
plot(gdpn, col="red", xlab="", ylab="", type="l");
text(75, 500, labels="Nominal", col="red");
lines(gdpr, col=c("blue"));
text(30, 1300, labels="Real", col="blue");
dev.off();
#end of code
the problem, of course, is that the text() function is not putting any
text in the plot. if i run this code *without* converting to time
series objects, the texts are placed as intended. i first tried
calling legend() on the time series plot and it also does not put any
legends. so my question is how can i put text/legend in a time series
plot? obviously there is a problem of how to specify the x coordinate
in a time series plot since the horizontal axis is time. if i call
par("usr"), it appears that the plotting coordinate is between 0 and
1. however, even if i specify the position as (0.5,0.5), the text
still does not appear in the graph. any help is appreciated.
h.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list