[R] where I can find more color names or color definition?

R. Michael Weylandt michael.weylandt at gmail.com
Wed Mar 14 16:27:06 CET 2012


Here's a function I stole from a blog post somewhere (I forgot where
and I'm pressed for time, but I'm sure google can recover it) -- it
might be helpful to you:

`col.wheel` <- function(str, nearby=3, cex=0.75) {
    cols <- colors()
	hsvs <- rgb2hsv(col2rgb(cols))
	srt <- order(hsvs[1,], hsvs[2,], hsvs[3,])
	cols <- cols[srt]
	ind <- grep(str, cols)
	if (length(ind) <1) stop("no colour matches found",
		call.=FALSE)
	#s.ind <- ind
	#if (nearby>1) for (i in 1:nearby) {
	#	s.ind <- c(s.ind, ind+i, ind-i)
	#}
	ind <- sort(unique(as.vector(outer(ind, -nearby:nearby, "+"))))
	ind <- ind[ind <= length(cols)]
	cols <- cols[ind]
	pie(rep(1, length(cols)), labels=cols, col=cols, cex=cex)
	cols
}

Behold, a good use of the bad ink/info ratio of a pie chart!

Michael


On Wed, Mar 14, 2012 at 11:06 AM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> apropos("color")
> ?colors
> colors()
>
> Michael
>
> On Wed, Mar 14, 2012 at 10:55 AM, Jie Tang <totangjie at gmail.com> wrote:
>> hi everyone .
>>  Now I want to draw several lines in one frame.And it seems needs more
>> colors except for blue red,black .Where can i found these color name or
>> define some new color ?thank you .
>>
>> --
>> TANG Jie
>> Email: totangjie at gmail.com
>> Tel: 0086-2154896104
>> Shanghai Typhoon Institute,China
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.



More information about the R-help mailing list