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

**URL:** <https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087>\
**Category:** ROOT\
**Created:** [September 2, 2017, 4:14pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087 "2017-09-02T16:14:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![enagy\_rootforum](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@enagy\_rootforum](https://root-forum.cern.ch/u/enagy_rootforum)\
**Post date:** [September 2, 2017, 4:14pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/1 "2017-09-02T16:14:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 2, 2017, 4:27pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/2 "2017-09-02T16:27:22Z")

</div>

[TColor](https://root.cern.ch/doc/master/classTColor.html)

---

<div class="post-metadata">

**Author:** ![enagy\_rootforum](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@enagy\_rootforum](https://root-forum.cern.ch/u/enagy_rootforum)\
**Post date:** [September 2, 2017, 5:24pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/3 "2017-09-02T17:24:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [September 2, 2017, 5:52pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/4 "2017-09-02T17:52:50Z")

</div>

[kInvertedDarkBodyRadiator](https://root.cern.ch/doc/master/TColor_8h.html#acb46d776ab87271c3fc10b14c50b169ca38c9d608eb4e164661fb1b4ab71a1996)

---

<div class="post-metadata">

**Author:** ![enagy\_rootforum](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@enagy\_rootforum](https://root-forum.cern.ch/u/enagy_rootforum)\
**Post date:** [September 2, 2017, 5:57pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/5 "2017-09-02T17:57:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 4, 2017, 1:29pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/6 "2017-09-04T13:29:43Z")

</div>

As said [here](https://root.cern.ch/doc/master/classTColor.html#C06) the high quality color palettes are available since 6.04.You can also define you own palette using the 2nd example of[this paragraph](https://root.cern.ch/doc/master/classTColor.html#C05).

---

<div class="post-metadata">

**Author:** ![enagy\_rootforum](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@enagy\_rootforum](https://root-forum.cern.ch/u/enagy_rootforum)\
**Post date:** [September 4, 2017, 2:00pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/7 "2017-09-04T14:00:57Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 5, 2017, 3:16pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/8 "2017-09-05T15:16:04Z")

</div>

`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](https://root-forum.cern.ch/t/inverted-color-palettes/24826) 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.

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

```

Forum post for the idea:

> [@Inverted Color Palettes](https://root-forum.cern.ch/t/inverted-color-palettes/24826):
>
> Hi, 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 …

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 5, 2017, 3:17pm UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/9 "2017-09-05T15:17:44Z")

</div>

> [@enagy\_rootforum](#):
>
> as I wrote in the Forum, I am using 6.08/00 and in this version neither TColor::InvertPalette(); nor kInvertedDarkBodyRadiator [ROOT: core/base/inc/TColor.h File Reference](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.

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

---

<div class="post-metadata">

**Author:** ![enagy\_rootforum](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@enagy\_rootforum](https://root-forum.cern.ch/u/enagy_rootforum)\
**Post date:** [September 6, 2017, 5:21am UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/10 "2017-09-06T05:21:59Z")

</div>

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:

```auto
  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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [September 6, 2017, 8:07am UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/11 "2017-09-06T08:07:44Z")

</div>

> [@enagy\_rootforum](#):
>
> kLakewater

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.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [September 20, 2017, 8:07am UTC](https://root-forum.cern.ch/t/how-to-change-the-color-panel-for-draw-colz-for-th2-plots/26087/12 "2017-09-20T08:07:48Z")

</div>

Closed on September 20, 2017, 8:07am UTC

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