Re: [R] What are the color's name in heat.color(5)

2012-03-28 Thread Eik Vettorazzi
Hi,
just one more note, col2rgb works for color codes as well:

(HC.m <- col2rgb(heat.colors(5)))

and to convert named colors to color codes, something like

tabl<-apply(col2rgb(colors()),2,function(x)do.call(rgb,c(as.list(x),alpha=255,maxColorValue=255)))
names(tabl)<-colors()
tabl

should work.

cheers

Am 28.03.2012 15:51, schrieb David Winsemius:
> 
> On Mar 28, 2012, at 9:08 AM, Kevin Wright wrote:
> 
>> They have hex RGB values instead of names:
>>
>> R> heat.colors(5)
> 
>> [1] "#FFFF" "#FF5500FF" "#FFAA00FF" "#00FF" "#80FF"
>>
>> Kevin
> 
> The first one is the same as 'red' as can be seen by parsing the RGB
> values above:
> 
>> col2rgb("red")
>   [,1]
> red255
> green0
> blue 0
> 
> HC.m < matrix( c( strtoi( substr(heat.colors(5), 2,3), 16L),
> strtoi(substr(heat.colors(5), 4,5), 16L), strtoi(substr(heat.colors(5),
> 6,7), 16L) ), nrow=3, byrow=TRUE)
> HC.m
>  [,1] [,2] [,3] [,4] [,5]
> [1,]  255  255  255  255  255
> [2,]0   85  170  255  255
> [3,]0000  128
> 
> One of the others 'yellow' is also in named colors:
> 
>> which( apply(col2rgb(colors()) , 2 , function(x) all( x ==
> c(HC.m[,2]))) )
> integer(0)
>> which( apply(col2rgb(colors()) , 2 , function(x) all( x ==
> c(HC.m[,3]))) )
> integer(0)
>> which( apply(col2rgb(colors()) , 2 , function(x) all( x ==
> c(HC.m[,1]))) )
> [1] 552 553
>> which( apply(col2rgb(colors()) , 2 , function(x) all( x ==
> c(HC.m[,4]))) )
> [1] 652 653
>> which( apply(col2rgb(colors()) , 2 , function(x) all( x ==
> c(HC.m[,5]))) )
> integer(0)
> 
>> colors()[552: 553]
> [1] "red"  "red1"
> 
>> colors()[652:653]
> [1] "yellow"  "yellow1"
> 


-- 
Eik Vettorazzi

Department of Medical Biometry and Epidemiology
University Medical Center Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790

--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf; Körperschaft des öffentlichen Rechts; 
Gerichtsstand: Hamburg

Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. 
Alexander Kirstein, Joachim Prölß, Prof. Dr. Dr. Uwe Koch-Gromus 

__
[email protected] 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.


Re: [R] What are the color's name in heat.color(5)

2012-03-28 Thread David Winsemius


On Mar 28, 2012, at 9:08 AM, Kevin Wright wrote:


They have hex RGB values instead of names:

R> heat.colors(5)



[1] "#FFFF" "#FF5500FF" "#FFAA00FF" "#00FF" "#80FF"

Kevin


The first one is the same as 'red' as can be seen by parsing the RGB  
values above:


> col2rgb("red")
  [,1]
red255
green0
blue 0

HC.m < matrix( c( strtoi( substr(heat.colors(5), 2,3), 16L),  
strtoi(substr(heat.colors(5), 4,5), 16L),  
strtoi(substr(heat.colors(5), 6,7), 16L) ), nrow=3, byrow=TRUE)

HC.m
 [,1] [,2] [,3] [,4] [,5]
[1,]  255  255  255  255  255
[2,]0   85  170  255  255
[3,]0000  128

One of the others 'yellow' is also in named colors:

> which( apply(col2rgb(colors()) , 2 , function(x) all( x == c(HC.m[, 
2]))) )

integer(0)
> which( apply(col2rgb(colors()) , 2 , function(x) all( x == c(HC.m[, 
3]))) )

integer(0)
> which( apply(col2rgb(colors()) , 2 , function(x) all( x == c(HC.m[, 
1]))) )

[1] 552 553
> which( apply(col2rgb(colors()) , 2 , function(x) all( x == c(HC.m[, 
4]))) )

[1] 652 653
> which( apply(col2rgb(colors()) , 2 , function(x) all( x == c(HC.m[, 
5]))) )

integer(0)

> colors()[552: 553]
[1] "red"  "red1"

> colors()[652:653]
[1] "yellow"  "yellow1"

--
David.



On Wed, Mar 28, 2012 at 7:24 AM, YN Kim  wrote:


Hi all,

I'm trying to using heat.color function in my data visualization.  
So, when
I set col = heat.color(5), five different colors are displayed from  
red to

weak yellow.

But, now I want to know the color's keys or the names of the  
displayed
heat.color. For instance, I think one of the five displayed colors  
seems to
be 'red'. But, I'm not sure whether it is, also I don't know the  
color

names for the others.

How can I know the exact colors name for that like 'red',  
'darkyellow' and

so on?

Thanks.

YN

  [[alternative HTML version deleted]]

__
[email protected] 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.





--
Kevin Wright

[[alternative HTML version deleted]]

__
[email protected] 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.


David Winsemius, MD
West Hartford, CT

__
[email protected] 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.


Re: [R] What are the color's name in heat.color(5)

2012-03-28 Thread Kevin Wright
They have hex RGB values instead of names:

R> heat.colors(5)
[1] "#FFFF" "#FF5500FF" "#FFAA00FF" "#00FF" "#80FF"

Kevin


On Wed, Mar 28, 2012 at 7:24 AM, YN Kim  wrote:

> Hi all,
>
> I'm trying to using heat.color function in my data visualization. So, when
> I set col = heat.color(5), five different colors are displayed from red to
> weak yellow.
>
> But, now I want to know the color's keys or the names of the displayed
> heat.color. For instance, I think one of the five displayed colors seems to
> be 'red'. But, I'm not sure whether it is, also I don't know the color
> names for the others.
>
> How can I know the exact colors name for that like 'red', 'darkyellow' and
> so on?
>
> Thanks.
>
> YN
>
>[[alternative HTML version deleted]]
>
> __
> [email protected] 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.
>



-- 
Kevin Wright

[[alternative HTML version deleted]]

__
[email protected] 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.