[R] plotting two variables with a third used for color
JiHO
jo.lists at gmail.com
Sun Mar 22 02:37:31 CET 2009
On 2009-March-20 , at 16:23 , David Winsemius wrote:
> On Mar 20, 2009, at 3:55 PM, Altaweel, Mark R. wrote:
>
>> I have a problem where I have two columns of data that I can simply
>> plot using:
>>
>> plot(wV[0:15,3],wY[0:15,3]).
>>
> Perhaps:
> plot(wV[0:15,3],wY[0:15,3], col = ifelse(wY[0:15,3]>0, "blue","red") )
And you could look into the package ggplot2 which gives you a legend
and is well suited for these things.
# quick version:
qplot(wV[0:15,3], wY[0:15,3], colour=ifelse(wY[0:15,3]>0,">0","<0"))
# more explicit version, using a data.frame
dat = data.frame(v=wV[0:15,3], y=wY[0:15,3],
sign=ifelse(wY[0:15,3]>0,">0","<0"))
ggplot(data=dat) + geom_point(aes(x=v,y=y,colour=sign))
JiHO
---
http://jo.irisson.free.fr/
More information about the R-help
mailing list