My Mail StationeryI have a question on plotting. Suppose I have two vectors x and y consisting of equal number of elements. Say x be the observed values of a time series and y be the fitted values. I would like to plot the two sets of data on the same graph. How would I go about doing this? If they are plotted on different graphs but in the same window like one would get if one used the command scatter.smooth with times series data, that would do too. Indrajit -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20011230/e65ddbe3/attachment.html
>From: "Indrajit SenGupta" <indra_calisto at yahoo.com> >Subject: [R] A question on plotting >My Mail StationeryI have a question on plotting. Suppose I have two vectors >x and y consisting of equal number of elements. Say x be the observed values >of a time series and y be the fitted values. I would like to plot the two >sets of data on the same graph. How would I go about doing this? If they are >plotted on different graphs but in the same window like one would get if one >used the command scatter.smooth with times series data, that would do too.To do the two in the same graph: plot(x) lines(y) or points(y) or matplot(cbind(x,y),type="l") To do separate graphs one above the other: par(mfrow=c(2,1)) plot(x) plot(y) In general, see ?plot ?matplot ?lines ?par You can do other things like set colors, ranges, axis labels, etc. Jon Baron -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> I have a question on plotting. Suppose I have two vectors x and y > consisting of equal number of elements. > Say x be the observed values of a time series and y be the fitted > values. I would like to plot the two sets of data on the same graph. > How would I go about doing this? If they are plotted on different > graphs but in the same window like one would get if one used the > command scatter.smooth with times series data, that would do too.Please, could you specify your question more precisely? Do you mean two plots (with seperate coordinate systems) or just two kinds of symbols (colors representing different types of values) in the same plot? Or .... ? Nevertheless, whatever you are asking right now, I guess your question (any kind of multiple plots in one window, if I understand right) is already answered in a) An Introduction to R, b) the FAQs, or c) the mailing list archives. But if you want to reproduce the behaviour of the function scatter.smooth(), simply look into its code, which is really simple to understand! --- and mainly consists of i) a call to loess.smooth() ii) the plot() iii) and adding some lines() Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._