How to find definitions of predefined palettes

I want to be able to invert a couple of ROOT’s predefined palettes using TColor::CreateGradientColorTable(). However, I’m having trouble finding how the original palettes are defined, and I’d rather not spend time guessing which colours to use. Does anyone know where to find the definitions?


ROOT Version: 6.10/04
Platform: Ubuntu 18.04 on Windows
Compiler: Cling


See the source code of: TColor::SetPalette

1 Like

When I tried to invert the palette, I got a very strange looking graph. I can’t figure out why.

Int_t kInvertedSolar[255];
Double_t stops[9] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
Double_t redS[9] = {230./255., 201./255., 201./255., 196./255., 200./255., 174./255., 154./255., 116./255., 99./255.};
Double_t greenS[9] = {173./255., 136./255., 119./255., 83./255., 58./255., 32./255., 8./255., 0./255., 0./255.};
Double_t blueS[9] = {24./255.,  19./255., 17./255., 14./255., 9./255., 9./255., 7./255., 6./255., 5./255.};
Int_t IdxS = TColor::CreateGradientColorTable(9, stops, redS, greenS, blueS, 255);
for (int i=0;i<100;i++) kInvertedSolar[i] = IdxS+i;

gStyle->SetPalette(255,kInvertedSolar);

image

I just reversed the order of the red, green, and blue arrays from the definition of kSolar at line 2956 of TColor.

You do not need to know the definition of a predefined palette to invert it. Use InvertPalette

1 Like

My ROOT version is too old for InvertPalette, but I don’t have anything else to do today, so I’ll try to update.
Hang tight, I’ll let you know when I give up.

See the source code of: TColor::InvertPalette

It took me three days to install ROOT the first time, but it turns out that it’s not that hard once you know what to do. It took me one try this time.
Now that I’m using a new version of ROOT, InvertPalette works beautifully! Thank you, @couet!
And thank you for your help finding the palettes, @Wile_E_Coyote!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.