Inverted Color Palettes


Is it possible to easily invert the predefined color palettes? There are some great palettes predefined, but in my opinion they are defined backwards. For example, kCherry runs from black to white through red. This looks good for 3D renderings, but is confusing for 2D histograms rendered with the "COLZ" option as empty bins (or those below the minimum) and the maximum bins are nearly the same color. I’d like the colors to run from white to black through red. This is true for many others as well: kGreyScale, kCoffee, kPigeon, etc. In general it would easily “double” the available number of palettes.

It would be nice if it was as simple as:


That’s a matter of taste… There is no such functionality right now.

Wasn’t so hard once I figured out what was going on in TColor.

Would this commit be appreciated as a pull request?

A short demonstration:


   TF2 *f = new TF2("xygaus", "xygaus", -2, 2, -2, 2);

   TH2D* h = new TH2D("h", "H", 50, -2, 2, 50, -2, 2);
   h->FillRandom("xygaus", 50000);

1 Like

I ran the palettes.C tutorial as well (with the additional TColor::InvertPalette() line) to give a nice comparison between inverted palettes and the regular ones, but I can’t upload pdfs here. So I attached a couple examples instead.

Here is the plot for kCherry:

Here is the plot for kGreyScale:

Here is the plot for kBird

1 Like

Many thanks for you contribution. Yes that’s not to hard to implement. I will take your code.

Now in place. Thanks for the suggestion.

1 Like

In the documentation you added, " The top of the palette becomes the bottom et vice versa." should read " The top of the palette becomes the bottom and vice versa."

1 Like

Thanks to have seen it so quickly. Fixed

It also has to be fixed in the documentation of the InvertPalette method :wink:

Damned you are right ! :slight_smile: Done… thanks,

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