How to change the color panel for Draw("colz") for TH2 plots?

I would like to change the color panel for the TH2->Draw(“colz”) option in such a way that the most
populated bin gets the darkest and the less populated one the faintest color, close to blank, which is
the color of the unfilled bin. At present the less populated bin is dark blue and the most populated bin
has light yellow color, just the inverse, I’d like to have.

TColor

I read TColor and would like to use
TColor::InvertPalette(); or
gStyle->SetPalette(kInvertedDarkBodyRadiation);
The documentation says in section High quality predefined palettes
it is since 6.04. However neither option exists in the version I am using,
i.e. in ROOT 6.08/00.
Can somebody tells which version should be used for the above commands?

kInvertedDarkBodyRadiator

Well, the problem is that this documentation says kInvertedDarkBodyRadiator =56,
but in version v 6.08/00 the enum 56 is assigned to kCherry. My question is, the above
documentation is valid since which version?

As said here the high quality color palettes are available since 6.04.You can also define you own palette using the 2nd example of this paragraph.

Hi,

as I wrote in the Forum, I am using 6.08/00 and in this version neither TColor::InvertPalette();
nor kInvertedDarkBodyRadiator https://root.cern.ch/doc/master/TColor_8h.html#acb46d776ab87271c3fc10b14c50b169ca38c9d608eb4e164661fb1b4ab71a1996 exists and the enum 56 corresponds to kCherry. So the
documentation has to be changed, telling the version since those items exist. It is certainly not 6.04.

Elemer

TColor::InvertPallete was added in version 6.10.00. Unfortunately, it looks like it was not added to the Change log for that version. Using the commit mentioned in the forum topic below you can add the functionality to any version by performing the same reversal if you have the palette. Another unfortunate issue is that TColor::GetPalette was not added until ROOT 6.11.01.

std::reverse(palette.fArray, palette.fArray + palette.GetSize());
TColor::SetPalette(palette);

Forum post for the idea:

Also, you are quoting the master documentation which is for the latest version. The documentation for ROOT 6.08 is available at https://root.cern.ch/doc/v608/classTColor.html (notice the v608 instead of master).

Hello,

thanks a lot for all those helpful informations. I still suggest to take out from the master documentation
the words “since 6.04” because it creates confusion and deception.
In the meantime I have created a palette which corresponds to my need. I like it very much so I share with you:
it makes a gradual transition white->green->blue:

  const Int_t Number = 3;
  Double_t Red[Number]    = { 1.00, 0.00, 0.00};                                                                                                    
  Double_t Green[Number]  = { 1.00, 1.00, 0.00};
  Double_t Blue[Number]   = { 1.00, 0.00, 1.00};
  Double_t Length[Number] = { 0.00, 0.50, 1.00 };
  Int_t nb=50;
  TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nb);

If hte ROOT developpers like it too, they can create a predefined palette with the name kLakewater or even better
kBalaton.

Elemer

Thanks for the suggestion. Indeed this palette definition is very simple. The pre-defined palettes are more for “non trivial palettes” or give some ideas of what can be done. We can add many palettes but at some point users can also use CreateGradientColorTable… this method is not for internal use only.

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