Re: [R] rgb and col2rgb color conversion/modification/shading

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Tue 01 Aug 2006 - 18:10:18 EST

ccarey@fhcrc.org wrote:
> I want to get a lighter shade of a color...I have a lot of colored objects and
> want each one printed as a foreground against a slightly lighter background.
>
> I thought I could try something like changing the alpha channel by first
> converting it to rgb.
>
> But prior to trying that, I'm stuck with how to get the color after converting
> using col2rgb() to be interpreted again as a color, rather than a simple
> vector?
>
> Anyone have any help/ or alternative suggestion...
>
> Thanks, -c
> ----------------------
> TRYING WITH A SINGLE COLOR:
>
> mycol<-"red"
>

>> col2rgb(mycol)

> [,1]
> red 255
> green 0
> blue 0
>
>> rgb(col2rgb(mycol),maxColorValue=255)

rgb() required separate arguments for red green and blue.

Hence saying

   mycol2 <- col2rgb(mycol)
   rgb(mycol2[1,], mycol2[2,], mycol2[3,], maxColorValue=255)

does not look like beautiful code, but is probably easier than the other "cool" tricks.

Uwe Ligges

> Error in rgb(col2rgb("red")) : argument "green" is missing, with no default
>
> ______________________________________________
> R-help@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.



R-help@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 Aug 01 18:23:20 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 01 Aug 2006 - 20:17:33 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.