[R] A question on plotting
Jonathan Baron
baron at cattell.psych.upenn.edu
Sat Dec 29 21:05:03 CET 2001
>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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list