Re: [R] Plot using colors

From: hadley wickham <>
Date: Mon, 03 Mar 2008 08:50:04 -0600

On Mon, Mar 3, 2008 at 4:03 AM, mysimbaa <> 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.

You might want to look at ggplot2,, which provides many tools to make this type of mapping easy. For example,

qplot(tvar, var, colour=varstability, geom="line")

might be sufficient in your case (although without a minimal reproducible example it's impossible to know)



______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 03 Mar 2008 - 14:54:16 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 - 15:30:18 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive