Re: [R] Plot using colors

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Mon, 03 Mar 2008 08:38:31 -0300

You want just the points with colors?

var <- rnorm(10)
vars <- rnorm(10)

plot(var, type='l')
points(var, col=ifelse(var < vars, 'green', 'red'), pch= 16)

or

the lines also?

for(i in 1:9)segments(i, var[i], i + 1, var[i+1], ifelse(var[i] < vars[i], 'green', 'red'))

On 03/03/2008, mysimbaa <adel.tekari_at_sisltd.ch> wrote:
>
> Dear R users,
> I have a problem since I try to plot my datas with different colors.
>
> plot(tvar, var, xlab="zeit [s]",ylab="Variation [%]", col = ifelse(var <=
> varstability, 'green','red'))
> this works well!
>
> But since I add a type="l" to my plot, it will color all the plot with
> green!!!
> Is there any solution? I avoid to use teachingDemos.
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/Plot-using-colors-tp15799930p15799930.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
R-help_at_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.
Received on Mon 03 Mar 2008 - 11:40:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 03 Mar 2008 - 12:30:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive