[R] Selecting complementary colours

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue May 22 00:44:32 CEST 2007


On 5/21/07, John Fox <jfox at mcmaster.ca> wrote:
> Dear r-helpers,
>
> I wonder whether, given the "#rrggbb" representation of a colour, there is a
> simple way to select the complementary colour, also expressed as a "#rrggbb"
> string.
>
> Any suggestions would be appreciated.

You want rgb2col. The following should work for any standard color
specification:

> mycol = "royalblue"
> do.call(rgb, as.list(1 - col2rgb(mycol) / 255))
[1] "#BE961E"

-Deepayan



More information about the R-help mailing list