[R] General means of matching a color specification to an official R color name
romain.francois at dbmail.com
Wed Oct 14 13:22:25 CEST 2009
On 10/14/2009 12:26 PM, Romain Francois wrote:
> On 10/14/2009 12:05 AM, Barry Rowlingson wrote:
>> On Tue, Oct 13, 2009 at 10:58 PM, Bryan Hanson<hanson at depauw.edu> wrote:
>>> Works perfectly! Thanks Barry. I had actually seen some suggestions on
>>> using a distance, but by then I was thinking about hcl spaces and
>>> isn't so as simple there. I'm too tired I think.
>>> Anyway, you've got me running again! Thanks, Bryan
>> There's a CPAN module for Perl that does hcl colour similarity:
>> the Perl code is pretty neat, looks easy to R-ify - released under
>> the perl license.
> There are a few unexported functions in the xterm256 package to deal
> with this.
> > colors()[ xterm256:::closest.character( "#aabbcc" ) ]
>  "gold4"
Actually that is wrong closest.character gives you the index of the
closest xterm256 color, as in : http://frexx.de/xterm-256-notes/
sorry for the misleading answer ...
> The package pretends it writes the text using the background of
> foreground color as usually represented in R, but it actually first
> grabs the closest color (in the RGB space according to the euclidian
> metric, I have no idea whether a different space or a different metric
> would be better)
> This presentation might give a clue :
Professional R Enthusiast
+33(0) 6 28 91 30 30
|- http://tr.im/BcPw : celebrating R commit #50000
|- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
`- http://tr.im/yw8E : New R package : sos
More information about the R-help