[R] Strategy for creating a palette...?

Kjetil Kjernsmo kjetil.kjernsmo at astro.uio.no
Wed Aug 8 12:31:49 CEST 2001


On 8 Aug 2001, Peter Dalgaard BSA wrote:

>> I've spent all evening, er, night trying to tune this, but it's still
>> ugly. My best shot so far is this:
>> greenred <- palette(rgb(exp(-(0:255)/80), exp(-(0:255)/80), 0))
>
>Um, that doesn't mean what I think you think it means.

Uh-oh. I just learnt something: If you're tired, don't even thing about
staying up to two o'clock trying to get things to work... :-)

Thanks a lot for replying anyway!

>Point 1: palette() returns the previous palette:

I remember reading that last night, but I guess I had a thick layer of
teflon on my brain at that time... :-) Sorry.
Now I understand, I wouldn't want to use palette at all, here.


>> greenred <- palette(rgb(exp(-(0:255)/80), exp(-(0:255)/80), 0))
>> greenred
>[1] "black"   "red"     "green3"  "blue"    "cyan"    "magenta" "yellow"
>[8] "white"

So, this worked for me only because the previous palette I defined was the
example I meant to use...

>Point2: rgb(exp(-(0:255)/80), exp(-(0:255)/80), 0) have equal amounts
>of red and green, so is varying degrees of dirty yellow.

Yep, what I had on my screen was of course
rgb(exp(-(255:0)/80), exp(-(0:255)/80), 0)

>> Any ideas...? Anybody got a pretty palette for this purpose? Also, I'd
>> like to tune the palette so that the break between green and red happens
>> at a value of e.g. 0.05. How would I do that?
>
>A code example that actually worked might have helped us...

No doubt about that... :-)

>Instinctively, I'd suggest you should play with hsv().

I played with that too. The result was even worse... :-) Now I realize
that was partly because I didn't realize the H scale in GIMP was 0:360,
I thought it was 0:255.

OK, now I've deviced something that looks a lot better:
h <- c((120:70)/360, 45/360, 25/360, (22:0)/360)
s <- 1
v <- c(rep(90/100, 51), rep(95/100, 2), rep(1, 23))
hsv(h,s,v)

Can I make sure that a value e.g. 0.05 corresponds to the color with index
52?

Best,

Kjetil
-- 
Kjetil Kjernsmo
Graduate astronomy-student                    Problems worthy of attack
University of Oslo, Norway            Prove their worth by hitting back
E-mail: kjetikj at astro.uio.no                                - Piet Hein
Homepage <URL:http://folk.uio.no/kjetikj/>
Webmaster at skepsis.no                            OpenPGP KeyID: 6A6A0BBC


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list