Re: [R] basic graphics

Ross Ihaka (ihaka@stat.auckland.ac.nz)
Tue, 8 Dec 1998 11:25:36 +1300 (NZDT)

Date: Tue, 8 Dec 1998 11:25:36 +1300 (NZDT)
From: Ross Ihaka <ihaka@stat.auckland.ac.nz>
Message-Id: <199812072225.LAA11224@stat1.stat.auckland.ac.nz>
To: r-help@stat.math.ethz.ch, tring@mail1.stofanet.dk
Subject: Re: [R] basic graphics

Here is a simple example showing how to use colors and symbols:

# create some fake data, x, y, and group
x <- runif(100)
y <- runif(100)
g <- rep(1:4, 25)

# colors: plot with col=1 for group1, col=2 for group2 ...
plot(x, y, col=g)

# symbols: plot with pch=1 for group1, pch=2 for group2 ...
plot(x, y, pch=g)

# Both colors and symbols
plot(x, y, col=g, pch=g)

# customised colors and symbols
plot(x, y, col=c("red","green","blue","yellow")[g])
plot(x, y, pch=c(1,3,7)[g])

To see why these last two work, just print the value of

c("red","green","blue","yellow")[g]

Hope this helps.
Ross
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


This archive was generated by hypermail 1.02.