[R] rgb and col2rgb color conversion/modification/shading
Uwe Ligges
ligges at statistik.uni-dortmund.de
Tue Aug 1 10:10:18 CEST 2006
ccarey at 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 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.
More information about the R-help
mailing list