FW: [R] Plotcorr: colour the ellipses to emphasize the differences

Gorjanc Gregor Gregor.Gorjanc at bfro.uni-lj.si
Sun Oct 17 20:33:48 CEST 2004


-----Original Message-----
From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca]
Sent: ned 2004-10-17 15:34
To: Gorjanc Gregor
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Plotcorr: colour the ellipses to emphasize the differences 
 
On Sun, 17 Oct 2004 02:51:58 +0200, "Gorjanc Gregor"
<Gregor.Gorjanc at bfro.uni-lj.si> wrote:

[removed old stuff] 

>>I would also like to know if it is possible to use some other scale of 
>> colors instead of cm.colors, rainbow, heat.colors, terrain.colors, 
>> topo.colors. I would like to have positive correlations in blue and 
>> nagative ones in red spectrum of colors. Is it possible?

> The source of cm.colors is visible (just type "cm.colors" and it will
> be printed).  You could write your own function to change the scale to
> blue through red instead of cyan through magenta by changing a few
> constants in that function.

Thanks, that helped me to do what I wanted. Thanks. Bellow is the code.

cm.colors <- function (n) 
{
    # from red
    from=0
    # to blue
    to=8/12
    if ((n <- as.integer(n[1])) > 0) {
        even.n <- n%%2 == 0
        k <- n%/%2
        l1 <- k + 1 - even.n
        l2 <- n - k + even.n
        c(if (l1 > 0) 
            hsv(h = from, 
                s = seq(0.5, ifelse(even.n, 0.5/k, 0), length = l1), 
                v = 1), 
          if (l2 > 1) 
            hsv(h = to, 
                s = seq(0, 0.5, length = l2)[-1], 
                v = 1))
    }
    else character(0)
}

> I think it would be useful to have a general function that did what
> cm.colors does but for other paths through colour space, but I've
> never written one (or done a thorough search to see if someone else
> has.)

I agree with this!

With regards,
    Gregor GORJANC




More information about the R-help mailing list