# Using predefined color palettes from root 6 to root 5

**URL:** <https://root-forum.cern.ch/t/using-predefined-color-palettes-from-root-6-to-root-5/41835>\
**Category:** Newbie\
**Created:** [October 13, 2020, 4:26am UTC](https://root-forum.cern.ch/t/using-predefined-color-palettes-from-root-6-to-root-5/41835 "2020-10-13T04:26:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AR10](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@AR10](https://root-forum.cern.ch/u/AR10)\
**Post date:** [October 13, 2020, 4:26am UTC](https://root-forum.cern.ch/t/using-predefined-color-palettes-from-root-6-to-root-5/41835/1 "2020-10-13T04:26:43Z")

</div>

Hi,

I’m trying to used the kBlackBody colour palette for my histogram, unfortunately its only available on root 6 while I’m still using root 5.38. Is there any way for me to still use this palette?

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [October 13, 2020, 6:08am UTC](https://root-forum.cern.ch/t/using-predefined-color-palettes-from-root-6-to-root-5/41835/2 "2020-10-13T06:08:47Z")

</div>

You can create a palette  
[https://root.cern.ch/doc/master/classTColor.html#C05](https://root.cern.ch/doc/master/classTColor.html#C05)

> [@Colour palette for periodic z-axis](https://root-forum.cern.ch/t/colour-palette-for-periodic-z-axis/41749/2):
>
> You can try creating your own colour palette, ensuring that the last point on the scale is the same colour as the first one. See the CreateGradientColorTable example in the “Color palettes” section on the page you linked. Based on the example there, you could have: { TCanvas \*c2 = new TCanvas("c2","c2",0,0,600,400); TF2 \*f2 = new TF2("f2","0.1+(1-(x-2)\*(x-2))\*(1-(y-2)\*(y-2))",1,3,1,3); const Int\_t Number = 4; Double\_t Red[Number] = { 1.00, 0.00, 0.00, 1.00}; Double\_t Green[Nu…

using the colours you want. You can see the values for the predefined palettes here:  
[ROOT: core/base/src/TColor.cxx Source File](https://root.cern/doc/master/TColor_8cxx_source.html#l02414)  
Scroll down to find Black Body (case 70). I’m not sure if the alpha option is available in ROOT 5, but you can just omit it, as in the “periodic z-axis” example above.

---

<div class="post-metadata">

**Author:** ![AR10](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@AR10](https://root-forum.cern.ch/u/AR10)\
**Post date:** [October 14, 2020, 12:01pm UTC](https://root-forum.cern.ch/t/using-predefined-color-palettes-from-root-6-to-root-5/41835/3 "2020-10-14T12:01:05Z")

</div>

Thank you for your reply,

Looking at the link for the predefined palettes, I couldn’t find the values for the colour they used (red,green,blue,length). Is there a link for the source file that has these values for the predefined palettes, or should I try to solve this by trial & error?

---

<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:** [October 14, 2020, 1:40pm UTC](https://root-forum.cern.ch/t/using-predefined-color-palettes-from-root-6-to-root-5/41835/4 "2020-10-14T13:40:31Z")

</div>

The code is:

```auto
      // Dark Body Radiator
      case 53:
         {
            Double_t red[9] = { 0./255., 45./255., 99./255., 156./255., 212./255., 230./255., 237./255., 234./255., 242./255.};
            Double_t green[9] = { 0./255., 0./255., 0./255., 45./255., 101./255., 168./255., 238./255., 238./255., 243./255.};
            Double_t blue[9] = { 0./255., 1./255., 1./255., 3./255., 9./255., 8./255., 11./255., 95./255., 230./255.};
            Idx = TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
         }

```

---

<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:** [May 24, 2022, 11:13am UTC](https://root-forum.cern.ch/t/using-predefined-color-palettes-from-root-6-to-root-5/41835/6 "2022-05-24T11:13:25Z")

</div>

> [@maxitop000](#):
>
> below we dropped a link to a possible solution

Where is that link ?
