[R] hcl()

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jun 24 11:14:47 CEST 2005


On Fri, 24 Jun 2005, Robin Hankin wrote:

> Hello everyone
>
> I am struggling with hcl().
>
> It says on the manpage that   "240 yields blue".
>
> With this:
>
> plot(1:50,pch=16,col=hcl(h=240, c=50, l=1:50))
>
> I get mostly blue, but also some red, dots.  Note that h=240
> throughout.  If 240 is blue,
> how come there's a red dot there?  Or is it just my monitor?

Looks at the values

> hcl(h=240, c=50, l=1:50)
  [1] "#130100" "#220100" "#2F0000" "#3E0000" "#530000" "#790000" "#FF0000"
  [8] "#0040BB" "#00338E" "#002F7C" "#002D73" "#002D6E" "#002E6A" "#002F69"
[15] "#003068" "#003167" "#003367" "#003568" "#003669" "#00386A" "#003A6B"
[22] "#003C6C" "#003E6E" "#00406F" "#004271" "#004473" "#004674" "#004976"
[29] "#004B78" "#004D7A" "#004F7C" "#00517E" "#005481" "#005683" "#005885"
[36] "#005B87" "#005D89" "#005F8C" "#08628E" "#126490" "#196693" "#1F6995"
[43] "#246B97" "#286E9A" "#2D709C" "#31729F" "#3575A1" "#3877A4" "#3C7AA6"
[50] "#3F7CA9"

3:7 are pure red.

Then try

> hcl(h=240, c=50, l=1:50, fixup=F)
  [1] NA        NA        NA        NA        NA        NA        NA
  [8] NA        NA        NA        NA        NA        NA        NA
[15] NA        NA        NA        NA        NA        NA        NA
[22] NA        NA        NA        NA        NA        NA        NA
[29] NA        NA        NA        NA        NA        NA        NA
[36] NA        NA        NA        "#08628E" "#126490" "#196693" "#1F6995"
[43] "#246B97" "#286E9A" "#2D709C" "#31729F" "#3575A1" "#3877A4" "#3C7AA6"
[50] "#3F7CA9"

You have mainly used invalid values: you cannot have high chroma and low 
luminance (and there are warnings to that effect on the help page).

Not sure the chosen mapping of out-of-gamut specs onto the sRGB gamut is 
particularly helpful, though.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list