Re: [R] Selecting complementary colours

From: John Fox <jfox_at_mcmaster.ca>
Date: Mon, 21 May 2007 20:22:53 -0400


Dear Achim,

As I mentioned in my response to Deepayan's suggestion, I didn't specify the original problem clearly: The object is to get contrasting colours, so that when one is plotted over the other, the two will be readily distinguishable. Your suggestions don't do this for neutral colours:

> x <- "#888888"
> y_hcl <- as(hex2RGB(x), "polarLUV")
> y_hcl_at_coords[1, "H"] <- y_hcl_at_coords[1, "H"] + 180
> hex(y_hcl)
[1] "#888888"  

> y_hsv <- as(hex2RGB(x), "HSV")
> y_hsv_at_coords[1, "H"] <- y_hsv_at_coords[1, "H"] + 180
> hex(y_hsv)
[1] "#888888"

Thank you for trying to help.

John



John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

> -----Original Message-----
> From: Achim Zeileis [mailto:Achim.Zeileis_at_wu-wien.ac.at]
> Sent: Monday, May 21, 2007 7:07 PM
> To: John Fox
> Cc: r-help_at_stat.math.ethz.ch
> Subject: Re: [R] Selecting complementary colours
>
> On Mon, 21 May 2007, John Fox 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.
>
> Is the complementary color uniquely defined? My understanding
> is that you can take opposite colors on a color wheel, but
> there are of course various color wheels available. With
> "colorspace" you can experiment with this,
> e.g.:
> x <- "#81A9D0"
> y_hcl <- as(hex2RGB(x), "polarLUV")
> y_hcl_at_coords[1, "H"] <- y_hcl_at_coords[1, "H"] + 180
> y_hcl <- hex(y_hcl)
> which is a bit more balanced than
> y_hsv <- as(hex2RGB(x), "HSV")
> y_hsv_at_coords[1, "H"] <- y_hsv_at_coords[1, "H"] + 180
> y_hsv <- hex(y_hsv)
>
> hth,
> Z
>
>
>



R-help_at_stat.math.ethz.ch 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 Tue 22 May 2007 - 00:32:31 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 Tue 22 May 2007 - 17:31:08 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.