[R] Natural colours for topographic data

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Nov 24 11:08:08 CET 2009


On Tue, Nov 24, 2009 at 8:42 AM, Karl Ove Hufthammer <karl at huftis.org> wrote:
> On Mon, 23 Nov 2009 12:21:03 -0500 David Winsemius
> <dwinsemius at comcast.net> wrote:
>> > I would be happy with a simple one, that just mapped negative values
>> > to water colours and positive values to land colours.
>>
>> Searching with the strategy "color positive negative zero" in r-search
>> and limiting it to r-help replies,  I get this Jim Lemon reply using
>> (naturally) plotrix's color.scale:
>>
>> http://finzi.psych.upenn.edu/R/Rhelp02/archive/90837.html
>>
>> The application to your needs looks pretty immediate.
>
> Thanks for the suggestion, but the arguments that 'color.scale' takes
> (range of red, green and blue values) makes it not very useful for this
> purpose.
>

 Have you tried my colourscheme package? Its not on CRAN but you can
get it from here:

http://r-forge.r-project.org/projects/colourscheme/

And can be installed thus:
 > install.packages("colourschemes",repos="http://r-forge.r-project.org")

 [sorry about the inconsistency between 'colourscheme' and 'colourschemes'!]

Vignette via r-forge's source code browser:
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/inst/doc/colourschemes.pdf?rev=19&root=colourscheme

 It defines various ways of mapping values to colours and using those
colours in plots. I use topographic-style colour schemes in the
examples, so this might be just what you want. The example in
?multiRamp is this:

# topological colour scheme - water, land, ice:
     tramp = multiRamp(rbind(c(-2000,0),c(0,1000),c(1000,9000)),
      list(c("black","blue"),c("green","brown"),c("gray70","gray70"))
      )

then:

 > tramp(-100)
 [1] "#0000F2FF"

 - is  a colour between black and blue in the ocean

> tramp(500)
 [1] "#539515FF"

 - is somewhere between green and brown in the land

 > tramp(1500)
 [1] "#B3B3B3FF"

 - is the gray of the ice.

No logarithmic colour scaling, but I do detail in the vignette how to
write your own colour scheme functions that are compatible with the
ones supplied. Will be glad to help more on this!

Barry




More information about the R-help mailing list