[R] Colour points in plot according to third variable
Jannis
bt_jannis at yahoo.de
Thu Jul 29 21:30:15 CEST 2010
check out the Plotrix package and the color.scale() or similar functions.
Henrique Dallazuanna schrieb:
> Try this:
>
> library(RColorBrewer)
> plot(iris$Sepal.Length,
> col = as.character(cut(iris$Sepal.Length, c(4,6,7,8), labels =
> brewer.pal(3, 'Blues'))))
>
>
>
> On Thu, Jul 29, 2010 at 2:51 PM, Anna Berthinussen <bs06ab at leeds.ac.uk>wrote:
>
>
>> 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
>>
>> ______________________________________________
>> 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.
>>
>>
>
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list