[R] multiple series on same graph

Ott Toomet siim at obs.ee
Wed Jan 30 08:45:20 CET 2002


Hi,

you should use col= and pch= graphical parameters for point type and color
correspondingly.  Legend get you with legend().  E.g. you can plot:

> x <- 1:10
> y1 <- x
> y2 <- sqrt(x)
> y3 <- log(x)
> plot(x,y1)
> points(x,y2,pch=2,col=3)
> points(x,y3,pch=3,col=4)
> legend(1.5,9, legend=c(expression(x), expression(sqrt(x)), expression(log(x))), pch=c(1,2,3), col=c(1,3,4))

instead of points(), you can consider also lines() wich draws a lines as
default.  The line type is controlled by lty= parameter.  To see different
possible point- and color types, use

> plot(0:30, pch=0:30, col=0:30)

Perhaps it helps.

Ott Toomet



On Tue, 29 Jan 2002, Collin Carbno wrote:

> I'm trying to duplicate some graphs from powerpoint in R package.  One
> of things I'm having trouble with is I don't understand how to use the
> points command to create different sets of points with different color
> and marking attributes, and a legend on the graph.  Where should I look?
> I can't seem to find an example of two different sets of data on the
> same graph.
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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