Re: [R] Drawing a colour wheel - bug in hcl?

From: Earl F. Glynn <efg_at_stowers-institute.org>
Date: Mon, 07 Jul 2008 16:30:57 -0500

"hadley wickham" <h.wickham_at_gmail.com> wrote in message news:f8e6ff050807071247nca6f950we6e4b95556862f20_at_mail.gmail.com...
> On Mon, Jul 7, 2008 at 1:05 PM, Earl F. Glynn <efg@stowers-institute.org>
> wrote:
>> "hadley wickham" <h.wickham_at_gmail.com> wrote in message >> news:f8e6ff050807070906y272bf4b9u7a356a5da0850653_at_mail.gmail.com...

> Well, I do have fixup = FALSE, which the documentation indicates
> should return NA if the chroma exceeds the actual upper bound.

You did specify fixup in the hcl data.frame but I'm not sure how that info was used when you called the hcl function since fixup is a parameter to the hcl function.

Compare the two plots from below. When you get the NAs you want, the odd colors go away, but I'm not sure you'll like the results:

# I dropped fixup from the data.frame (and used variable names that "Code Complete 2" might approve):

hcl.grid <- expand.grid(hue = seq(0, 360, by = 2),

                        chroma = 70,
                        luminance = seq(0, 100, by= 2))

hcl.grid <- transform(hcl.grid,
  angle = hue * pi / 180,
  radius = luminance / 100
)

hcl.grid <- transform(hcl.grid,
  x = radius * sin(angle),
  y = radius * cos(angle)
)

# What you have
hcl.grid$colour1 <- hcl(hcl.grid$hue, hcl.grid$chroma, hcl.grid$luminance,

                        fixup=TRUE)

with(hcl.grid, plot(x, y, col=colour1, pch=20))

# What you intended?
hcl.grid$colour2 <- hcl(hcl.grid$hue, hcl.grid$chroma, hcl.grid$luminance,

                        fixup=FALSE)

with(hcl.grid, plot(x, y, col=colour2, pch=20))

efg

Earl F Glynn
Bioinformatics
Stowers Institute for Medical Research



R-help_at_r-project.org 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 Mon 07 Jul 2008 - 21:38:27 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 Mon 07 Jul 2008 - 22:31:25 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.

list of date sections of archive