[R] Drawing a colour wheel - bug in hcl?
Earl F. Glynn
efg at stowers-institute.org
Mon Jul 7 20:05:01 CEST 2008
"hadley wickham" <h.wickham at gmail.com> wrote in message
news:f8e6ff050807070906y272bf4b9u7a356a5da0850653 at mail.gmail.com...
> there's some
> oddly bright colours of the wrong hue around c(0, 0) and I see three
> coloured circles (a small magenta, a medium sized yellow and a large
> cyan). Am I doing something wrong or is there a bug in the hcl code?
You set c = 70 = constant
from ?hcl:
c The chroma of the color. The upper bound for chroma depends on hue
and luminance
You seem to have used the full range of possible hue and luminance values.
Perhaps your odd colored circles are violations on valid values of chroma?
R's HCL documentation (?hcl) isn't very helpful. Foley and van Dam discuss
HLS, HSB, HSV, HVC color spaces in the "Computer Graphics" book, but not
HCL. The hcl function "corresponds to polar coordinates in the CIE-LUV color
space" but it's not clear how one converts from CIELUV to rgb from this
page: http://en.wikipedia.org/wiki/CIELUV_color_space.
BTW, the R documentation should be changed to eliminate "l" ("el") as
formal argument to the hcl function.
The book "Code Complete 2" suggests (p. 287) to "avoid names containing
hard-to-read characters". I'd suggest "l" ("el") is perhaps the worst
possible variable name since it can so easily be confused with "1" ("one").
Also, using "hcl" in different ways in the same code is also discouraged by
"Code Complete 2". Again on p. 287: "Avoid the names of standard types,
variables, and routines." If "hcl" is a "standard" routine, using "hcl" as
a variable name in the same code example using the "hcl" function is not
recommended and is confusing.
efg
Earl F Glynn
Bioinformatics
Stowers Institute for Medical Research
More information about the R-help
mailing list