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

From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>
Date: Mon, 07 Jul 2008 23:37:40 +0200 (CEST)

Hadley:

> I'm trying trying to draw a colour wheel (a slice of hcl space) in R.
> Running the code below doesn't give me what I expect - 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?

All of these have been fixed and do not correspond to HCL colors.

> hcl <- expand.grid(h = seq(0, 360, by = 2), c = 70, l = seq(0, 100, by
> = 2), fixup=FALSE)
> hcl <- transform(hcl,
> angle = h * pi / 180,
> radius = l / 100
> )
> hcl <- transform(hcl,
> x = radius * sin(angle),
> y = radius * cos(angle)
> )
> hcl$colour <- hcl(hcl$h, hcl$c, hcl$l)

If you replace this by

   hcl$colour <- hcl(hcl$h, hcl$c, hcl$l, fixup = FALSE)

> with(hcl, plot(x, y, col=colour, pch=20))

Then, the resulting "wheel" has three overlapping "holes" corresponding to the colors previously fixed.

Also, as hue/chroma correspond to polar coordinates in the UV plane of CIELUV, it makes more sense to plot wheels in the hue/chroma plane for fixed luminance. To draw a hue/luminance plane for fixed chroma is harder to interpret geometrically.

hth,
Z

> --
> http://had.co.nz/
>
> ______________________________________________
> 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.
>
>



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:43:10 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