[R] Colour points in plot according to third variable

Anna Berthinussen bs06ab at leeds.ac.uk
Thu Jul 29 19:51:20 CEST 2010


Hi,

I am using the plot function to make a simple plot of my data with one  
variable against another and want to colour the data points according  
to a third variable. The third variable is continuous (Time) and I  
want to try two different ways of colouring the data points, either:

Divide time it into three groups and then colour each data point  
accordingly eg. 30-60 minutes in green, 60-90 minutes in red and  
90-120 minutes in blue..

or,

Colour the data points using a colour gradient eg. with increasing  
colour intensity as time increases..

I think I need to be able to do it within the plot() function as I  
have lines fitted from a model which I will also add to the graph.

Any suggestions would be greatly appreciated??

Thanks in advance

Anna



More information about the R-help mailing list