Distinguishable Color Index

Here are two functions to color stuff with easy to distinguish colors. Although the first one has more colors, the second one is recommended for publishing graphs.

function KellysColors(index, ColorToReturn) //index[0-21], ColorToReturn[1-3] (= R, G, B)
    variable index, ColorToReturn
    // returns the 16-bit r, g, b values of the maximum contrast colors according to Kelly, see
    // http:// eleanormaclure.files.wordpress.com/2011/03/colour-coding.pdf
    // string/g KellysColorsNames="White;Black;Yellow;Purple;Orange;Light Blue;Red;Buff;Grey;Green;Purplish Pink;"
    // KellysColorsNames+="Blue;Yellowish Pink;Violet;Orange Yellow;Purplish Red;Greenish Yellow;Reddish Yellow;"
    // KellysColorsNames+="Yellow Green;Yellowish Brown;Reddish Orange;Olive Green;"
    make/W/U/free/N=22 Reds={255,31,235,111,219,151,185,194,127,98,211,69,220,72,225,145,233,125,147,110,209,44}
    make/W/U/free/N=22 Greens={255,30,205,48,106,206,32,188,128,166,134,120,132,56,161,39,232,23,173,53,45,54}
    make/W/U/free/N=22 Blues={255,30,62,139,41,230,54,130,129,71,178,179,101,150,49,139,87,22,60,21,39,23}
    // adjust to 16 bit range:
    Reds*=257
    Greens*=257
    Blues*=257     
    if (ColorToReturn==1)
        return(Reds[index])
    elseif (ColorToReturn==2)
        return(Greens[index])
    elseif (ColorToReturn==3)
        return(Blues[index])
    endif
    // default to black on error:
    return 0
end


The second function has less colors but is recognizable even for people with color deficiencies:
function ColorBlindColors(index, ColorToReturn) //index[0-7], ColorToReturn[1-3] (= R, G, B)
    variable index, ColorToReturn
    // returns the 16-bit r, g, b values of the maximum contrast colors optimized for colorblind people, see
    // http:// jfly.iam.u-tokyo.ac.jp/color/
    // string/g CUDOColorsNames="Black;Orange;Sky Blue;Bluish Green;Yellow;Blue;Vermilion;Reddish Purple;"
    make/W/U/free/N=8 Reds={0,230,86,0,240,0,213,204}
    make/W/U/free/N=8 Greens={0,159,180,158,228,114,94,121}
    make/W/U/free/N=8 Blues={0,0,233,115,66,178,0,167}
    // adjust to 16 bit range:
    Reds*=257
    Greens*=257
    Blues*=257     
    if (ColorToReturn==1)
        return(Reds[index])
    elseif (ColorToReturn==2)
        return(Greens[index])
    elseif (ColorToReturn==3)
        return(Blues[index])
    endif
    // default to black on error:
    return 0
end


You can either use these functions to create a color index wave and access this from your macros and functions:
make/O/N=(22,3) CI_KellysColors
CI_KellysColors=KellysColors(p,q+1)

or directly:
ModifyGraph rgb(MyTraceName#1)=(ColorBlindColors(1,1),ColorBlindColors(1,2),ColorBlindColors(1,3))


I have put spaces in the links so the forum would not mess up the code. The names of the colors are given as a global string at the top of the function, but as a comment to not mess up your folders. Uncomment at your own risk.
Do you know about Graph->Packages->Make Traces Different? This has a solution to a similiar problem.
The shifting to 16bit is incorrect.

You have to multiply by 2^16/(2^8 - 1) = 2^8 + 1 instead of 256.
16-bit calculation has been changed.
Thank you for your input. Of course you are correct concerning the 16 bit calculation. That was just pure laziness on my part, or maybe I have been hanging around the FPGA guys to long.

Other than the Color Wheel from the Make Traces Different-package where the hue difference is spread according to the number of waves these color palettes are intentionally limited to just a few entries. You just pick the next color and can be sure to have a maximum distance in color space to the previous entries. If you need more than 21 colors you should think about changing your layout, since from there on the colors start to become indistinguishable. I guess these color palettes would be the perfect upgrade for the CommonColorsButtonProc.
Unlike the Igor color presets these color palettes are not useful for encoding strength or magnitude, since there is no gradual increase visible.

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More