# [R] basic graphics

Ross Ihaka ihaka at stat.auckland.ac.nz
Mon Dec 7 23:25:36 CET 1998

```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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```