Re: [R] How to plot with different colours
Carlos Morales wrote: > Hello everyone, > > I'm trying to plot 3600 points and my idea is if this value is higher than 0.35 then this point must appear in green colour, if it's smaller than -0.35 then values must appear in red and if values are between -0.35 and 0.35 they must be in yellow. I'm thinking and I'm trying many things but I don't achieve it. Any idea?. Hi Carlos, This may be what you want: zeep<-rnorm(20) zeepcut<-as.numeric(cut(zeep,c(-4,-0.35,0.35,4))) plot(zeepcut,col=c("red","yellow","green")[zeepcut]) Jim -- At the risk of promoting my own code :-), if you want to plot lines with this sort of value-dependent color instead of points (or in addition), the function clplot() in the Plotrix package will do it for you. Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to plot with different colours
Hi Carlos, I'd strongly urge to reconsider your colour choices - 7-10% of males are red-green colour blind and it will be difficult for them to tell the difference between the high and low values. Hadley On Sat, Nov 1, 2008 at 11:58 PM, Carlos Morales <[EMAIL PROTECTED]> wrote: > Hello everyone, > > I'm trying to plot 3600 points and my idea is if this value is higher than > 0.35 then this point must appear in green colour, if it's smaller than -0.35 > then values must appear in red and if values are between -0.35 and 0.35 they > must be in yellow. I'm thinking and I'm trying many things but I don't > achieve it. Any idea?. > > Thanks so much > Carlos Morales Diego > > > > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to plot with different colours
Carlos Morales wrote: Hello everyone, I'm trying to plot 3600 points and my idea is if this value is higher than 0.35 then this point must appear in green colour, if it's smaller than -0.35 then values must appear in red and if values are between -0.35 and 0.35 they must be in yellow. I'm thinking and I'm trying many things but I don't achieve it. Any idea?. Hi Carlos, This may be what you want: zeep<-rnorm(20) zeepcut<-as.numeric(cut(zeep,c(-4,-0.35,0.35,4))) plot(zeepcut,col=c("red","yellow","green")[zeepcut]) Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to plot with different colours
On Sun, 2008-11-02 at 07:58 +, Carlos Morales wrote: > Hello everyone, > > I'm trying to plot 3600 points and my idea is if this value is higher than > 0.35 then this point must appear in green colour, if it's smaller than -0.35 > then values must appear in red and if values are between -0.35 and 0.35 they > must be in yellow. I'm thinking and I'm trying many things but I don't > achieve it. Any idea?. > > Thanks so much > Carlos Morales Diego Hi Carlos I think you need use a nested ifelse, something similar this x<-runif(6000,-1,1) color<-ifelse(x>.35,"green",ifelse(x< -.35,"red","yellow")) table(col) plot(1:6000,x,col=color) -- Bernardo Rangel Tura, M.D,MPH,Ph.D National Institute of Cardiology Brazil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to plot with different colours
Hello everyone, I'm trying to plot 3600 points and my idea is if this value is higher than 0.35 then this point must appear in green colour, if it's smaller than -0.35 then values must appear in red and if values are between -0.35 and 0.35 they must be in yellow. I'm thinking and I'm trying many things but I don't achieve it. Any idea?. Thanks so much Carlos Morales Diego __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.