Re: [R] Representing a statistic as a colour on a 2d plot

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Thu, 10 May 2007 17:49:20 +1000

mister_bluesman wrote:
> Ive been getting the color.scale function to work. However, I really need to
> know is that if i have values: 0.1 0.2, 0.3, 0.4, 0.5, for example, how I
> can plot these using colours that would be different if the contents of the
> file were 0.6, 0.7, 0.8, 0.9 and 1.0. Using color.scale scales them so that
> they differ, but only relative to each other, rather than taking the actual
> value and converting them to some unique colour/colour intensity.
>
> Many thanks
>
There are a couple of ways to go about this. If you know that there are say ten possible values, you can use the color.gradient function to assign ten colors across a particular range. Then you would have to map the colors to the numbers (I would do something like creating a two element list of the sorted unique numbers and the colors. Then assign the color vector for the plot from this list.) Note that both color.scale and color.gradient are aimed at producing colors that visually represent some range like cold(blue) to hot(red). If you just want to get 20 easily discriminated colors and assign them to values, you might be better off with ColorBrewer.

Jim



R-help_at_stat.math.ethz.ch 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 Thu 10 May 2007 - 07:52:49 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 Thu 10 May 2007 - 12:31:15 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.