[R] R-help Digest, Vol 35, Issue 7
ka4alin at yandex.ru
Sun Jan 8 21:01:44 CET 2006
Uwe Ligges Ð¿Ð¸ÑÐµÑ:
> Evgeniy Kachalin wrote:
>> Hello, dear participants!
>> Could you tip me, is there any simple and nice way to build
>> scatter-plot for three different types of data (, and o and * - signs,
>> for example) with legend.
>> Now i can guess only that way:
>> plot(x~y,data=subset(mydata,factor1=='1'), pch='.',col='blue')
>> points(x~y,data=subset(mydata,factor1=='2'), pch='*',col='green')
>> points(.... etc
>> What is the simple and nice way?
>> Thank you very much for your kindness and help.
> plot(Sepal.Length, Sepal.Width, pch = as.integer(Species)))
> legend(7, 4.4, legend = unique(as.character(Species)),
> pch = unique(as.integer(Species))))
Uwe, sorry for my stupid question. You mean that when pch=factor , plot
can recycle the factor and use it for subscripts or marks.
Then pch=as.integer(Species) results in c(1,2,3) for 3 factor levels.
And I need symbols 15,16,17 and colors red, blue, green.
So then I do:
That's the only way?
More of that!!! 'Plot' does not like factors in 'pch'. So it must be so:
That's totally crazy...
More information about the R-help