[R] symbol

Thomas Lumley tlumley at u.washington.edu
Tue Jan 28 17:34:02 CET 2003


On Tue, 28 Jan 2003, Luis Silva wrote:

> Ok, this works. But I have this problem. I have a loop to make
> each plot. Like this:
>
> plot(class 1, pch='1',...)
> for j (in 2:n)
> points(class 2, pch='j',...)
> ...
>
> of course pch='j' doesn't work. It generates other symbols. I
> accept also different colors instead of numbers

pch='j' doesn't do what you want because 'j' is a fixed letter not a
a variable want pch=j or pch=as.character(j).

Also, you can do this in one plot() command. For example, using the iris
dataset

data(iris)
plot(Sepal.Length~Petal.Length,pch=as.numeric(Species),data=iris)
or colours as well
plot(Sepal.Length~Petal.Length,pch=as.numeric(Species),col=as.numeric(Species),data=iris)

	-thomas




More information about the R-help mailing list