# Formatting colour palette with threshold values

**URL:** <https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761>\
**Category:** ROOT\
**Created:** [May 7, 2021, 3:10pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761 "2021-05-07T15:10:04Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 7, 2021, 3:10pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/1 "2021-05-07T15:10:04Z")

</div>

Consider this example:

```auto

const unsigned char n = 3;
  Int_t colours[n] = {kGreen -10, kGreen -6, kGreen + 1};
  gStyle -> SetPalette(n, colours);
  gStyle -> SetPaintTextFormat("2.2f");
  gStyle -> SetOptStat(0);
  TH2 * h = new TH2F("h", "h", 3, -0.5, 2.5, 3, -0.5, 2.5);
  h -> Fill(0.0, 0.0, 0.62);
  h -> Fill(0.0, 1.0, 0.51);
  h -> Fill(0.0, 2.0, 0.4);

  h -> Fill(1.0, 0.0, 0.2);
  h -> Fill(1.0, 1.0, 0.7);
  h -> Fill(1.0, 2.0, 0.26);

  h -> Fill(2.0, 0.0, 0.1);
  h -> Fill(2.0, 1.0, 0.27);
  h -> Fill(2.0, 2.0, 0.66);

  TCanvas * c = new TCanvas;
  h -> Draw("COLZTEXT");
  h -> SetMarkerSize(3.0);

```

The output is:

 ![matrix](https://root-forum.cern.ch/uploads/default/original/3X/0/f/0f892f5f6ea955a0dbb6fb0fc433fe0eeedc7402.png)

I would like to change the colour palette in the following way:

light green applies to values [ 0.0; 0.5 )  
medium green - [ 0.5; 0.6 )  
dark green - [0.6; 1.0001]

(the values define important thresholds).

How could I adjust the colour palette in this manner.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [May 7, 2021, 5:51pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/2 "2021-05-07T17:51:16Z")

</div>

@couet will most probably help you (next week)

---

<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 10, 2021, 11:05am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/3 "2021-05-10T11:05:12Z")

</div>

You want to link the histogram content to the colormap. The following example shows how to do it. You will need to have 2 `val_cut` instead of one.  
[https://root.cern/doc/master/perceptualcolormap\_8C.html](https://root.cern/doc/master/perceptualcolormap_8C.html)

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 10, 2021, 2:08pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/4 "2021-05-10T14:08:40Z")

</div>

I modified my example according to [ROOT: tutorials/graphics/perceptualcolormap.C File Reference](https://root.cern/doc/master/perceptualcolormap_8C.html)

```auto

const unsigned char Number = 6;
  // Int_t colours[Number] = {kGreen -10, kGreen -6, kGreen + 1};                                                                                                               

  Double_t Red[Number] = {0.75, 0.75, 0.0, 0.0, 0.0, 0.0,};
  Double_t Green[Number] = {1.0, 1.0, 0.3, 0.3, 0.7, 0.7 };
  Double_t Blue[Number] = {0.75, 0.75, 0.0, 0.0, 0.0, 0.0 };
  Double_t Stops[Number] = {0.0, 0.5, 0.50001, 0.6, 0.6000001, 1.0};
  TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, 3);
  // gStyle -> SetPalette(n, colours);                                                                                                                                          
  gStyle -> SetPaintTextFormat("2.2f");
  gStyle -> SetOptStat(0);
  TH2 * h = new TH2F("h", "h", 3, -0.5, 2.5, 3, -0.5, 2.5);
  h -> Fill(0.0, 0.0, 0.62);
  h -> Fill(0.0, 1.0, 0.51);
  h -> Fill(0.0, 2.0, 0.4);

  h -> Fill(1.0, 0.0, 0.2);
  h -> Fill(1.0, 1.0, 0.7);
  h -> Fill(1.0, 2.0, 0.26);

  h -> Fill(2.0, 0.0, 0.1);
  h -> Fill(2.0, 1.0, 0.27);
  h -> Fill(2.0, 2.0, 0.66);
  h -> SetMinimum(0.0);
  h -> SetMaximum(1.0);
  TCanvas * c = new TCanvas;
  h -> Draw("COLZTEXT");
  h -> SetMarkerSize(3.0);

```

In the output:

 ![matrix](https://root-forum.cern.ch/uploads/default/original/3X/7/d/7dab1c12b3a2dfb1965d5ca7b1e79157708798a4.png)

1. why are there 2 colours instead of 3?
2. why 0.4 is the same colour as 0.51?

How to express light green, medium green and dark green as a combination of RGB?

---

<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 10, 2021, 3:13pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/5 "2021-05-10T15:13:17Z")

</div>

```auto
void viesturs2()
{
   const unsigned char Number = 6;

   Double_t Red[Number] = {0.75, 0.75, 0.0, 0.0, 0.0, 0.0,};
   Double_t Green[Number] = {1.00, 1.00, 0.3, 0.3, 0.7, 0.7 };
   Double_t Blue[Number] = {0.75, 0.75, 0.0, 0.1, 0.0, 0.0 };
   Double_t Stops[Number] = {0.00, 0.50, 0.50001, 0.6, 0.6000001, 1.0};
   TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, 10);

   gStyle -> SetPaintTextFormat("2.2f");
   gStyle -> SetOptStat(0);
   TH2 * h = new TH2F("h", "h", 3, -0.5, 2.5, 3, -0.5, 2.5);
   h -> Fill(0.0, 0.0, 0.62);
   h -> Fill(0.0, 1.0, 0.51);
   h -> Fill(0.0, 2.0, 0.4);

   h -> Fill(1.0, 0.0, 0.2);
   h -> Fill(1.0, 1.0, 0.7);
   h -> Fill(1.0, 2.0, 0.26);

   h -> Fill(2.0, 0.0, 0.1);
   h -> Fill(2.0, 1.0, 0.27);
   h -> Fill(2.0, 2.0, 0.66);
   h -> SetMinimum(0.0);
   h -> SetMaximum(1.0);

   TCanvas * c = new TCanvas;
   h -> Draw("COLZTEXT");
   h -> SetMarkerSize(3.0);
}

```

 ![Screenshot 2021-05-10 at 17.12.44](https://root-forum.cern.ch/uploads/default/original/3X/1/6/16762df2ec56d0286fe658dee57dc5448528c4bd.jpeg)

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 10, 2021, 3:33pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/6 "2021-05-10T15:33:13Z")

</div>

Final question - I added a new TH2 \* h2:

```auto
const unsigned char Number = 6;
   Int_t colours[Number] = {kGreen -10, kGreen -6, kGreen + 1};

  Double_t Red[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2,};
  Double_t Green[Number] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
  Double_t Blue[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2 };
  Double_t Stops[Number] = {0.0, 0.5, 0.50001, 0.6, 0.6000001, 1.0};

  TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, 10);
  // gStyle -> SetPalette(n, colours);                                                                                                                                          
  gStyle -> SetPaintTextFormat("2.2f");
  gStyle -> SetOptStat(0);
  TH2 * h = new TH2F("h", "h", 3, -0.5, 2.5, 3, -0.5, 2.5);
  h -> Fill(0.0, 0.0, 0.62);
  h -> Fill(0.0, 1.0, 0.51);
  h -> Fill(0.0, 2.0, 0.4);

  h -> Fill(1.0, 0.0, 0.2);
  h -> Fill(1.0, 1.0, 0.7);
  h -> Fill(1.0, 2.0, 0.26);

  h -> Fill(2.0, 0.0, 0.1);
  h -> Fill(2.0, 1.0, 0.27);
  h -> Fill(2.0, 2.0, 0.66);
  h -> SetMinimum(0.0);
  h -> SetMaximum(1.0);
  TCanvas * c = new TCanvas;
  h -> Draw("COLZTEXT");
  h -> SetMarkerSize(3.0);
  TH2 * h2 = new TH2F("h2", "h2", 2, -0.5, 1.5, 2, -0.5, 1.5);
  h2 -> Fill(0.0, 0.0, 2.0);
  h2 -> Fill(0.0, 1.0, 2.5);
  h2 -> Fill(1.0, 0.0, 0.5);
  h2 -> Fill(1.0, 1.0, 1.5);
  TCanvas *c2	= new TCanvas;
  h2 -> Draw("COLZ");

```

How can I draw the new h2 with the standard ROOT colour palette?

---

<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 11, 2021, 8:18am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/7 "2021-05-11T08:18:07Z")

</div>

> [@Viesturs](#):
>
> How can I draw the new h2 with the standard ROOT colour palette?

[https://root.cern/doc/master/multipalette\_8C.html](https://root.cern/doc/master/multipalette_8C.html)

---

<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 11, 2021, 9:21am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/8 "2021-05-11T09:21:27Z")

</div>

You can also may be use the CJUST option as shown [here](https://root-forum.cern.ch/t/alignment-of-labels-in-tpaletteaxis-at-color-boundaries/32917/6).

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 11, 2021, 11:35am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/9 "2021-05-11T11:35:09Z")

</div>

The example fails when I multiply all stops and bin contents by 100:

```auto
  const unsigned char Number = 6;

  Double_t Red[Number] = {0.75, 0.75, 0.0, 0.0, 0.0, 0.0,};
  Double_t Green[Number] = {1.00, 1.00, 0.3, 0.3, 0.7, 0.7 };
  Double_t Blue[Number] = {0.75, 0.75, 0.0, 0.1, 0.0, 0.0 };
  //Double_t Stops[Number] = {0.00, 0.50, 0.50001, 0.6, 0.6000001, 1.0};                                                                                                                                                                                                                                                                                        
  Double_t Stops[Number] = {0.00, 50.0, 50.001, 60.0, 60.00001, 100.0};
  TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, 10);

  gStyle -> SetPaintTextFormat("2.2f");
  gStyle -> SetOptStat(0);
  TH2 * h = new TH2F("h", "h", 3, -0.5, 2.5, 3, -0.5, 2.5);
  h -> Fill(0.0, 0.0, 62.0);
  h -> Fill(0.0, 1.0, 51.0);
  h -> Fill(0.0, 2.0, 40.0);

  h -> Fill(1.0, 0.0, 20.0);
  h -> Fill(1.0, 1.0, 70.0);
  h -> Fill(1.0, 2.0, 26.0);

  h -> Fill(2.0, 0.0, 10.0);
  h -> Fill(2.0, 1.0, 27.0);
  h -> Fill(2.0, 2.0, 66.0);
  h -> SetMinimum(0.0);
  h -> SetMaximum(100.0);

  TCanvas * c = new TCanvas;
  h -> Draw("COLZTEXT");
  h -> SetMarkerSize(3.0);

```

 ![palette_test](https://root-forum.cern.ch/uploads/default/original/3X/7/3/732b2e57ad73923bb509e8c798beac6401e00f88.png)

Could you please help me find what is wrong?

---

<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 11, 2021, 11:48am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/10 "2021-05-11T11:48:28Z")

</div>

Look at the doc of [CreateGradineColorTable](https://root.cern/doc/master/classTColor.html#aea9a467ba2ab61a20f86d9587805e2cc) . The STOPS values are between 0 and 1 . You removed that part of the code from the original macro I gave you ☹

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 11, 2021, 12:04pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/11 "2021-05-11T12:04:29Z")

</div>

Is there a function to get RGB values of kGreen + 10?

---

<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 11, 2021, 12:20pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/12 "2021-05-11T12:20:15Z")

</div>

```auto
root [0] float r,g,b;
root [1] TColor *color = gROOT->GetColor(kGreen+10);
root [2] color->GetRGB(r,g,b)
root [3] cout << r << " " << g << " " << b << endl;
0.4 0.8 0.8

```

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 11, 2021, 3:11pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/13 "2021-05-11T15:11:35Z")

</div>

I am trying the mulitpalette example:

```auto
void pal();
int palette()
{
  TExec * ex = new TExec("ex", "pal();");
  TH2 * h = new TH2F("h", "h", 3, -0.5, 2.5, 3, -0.5, 2.5);
  h -> Fill(0.0, 0.0, 0.62);
  h -> Fill(0.0, 1.0, 0.51);
  h -> Fill(0.0, 2.0, 0.4);

  h -> Fill(1.0, 0.0, 0.2);
  h -> Fill(1.0, 1.0, 0.7);
  h -> Fill(1.0, 2.0, 0.26);

  h -> Fill(2.0, 0.0, 0.1);
  h -> Fill(2.0, 1.0, 0.27);
  h -> Fill(2.0, 2.0, 0.66);
  h -> SetMinimum(0.0);
  h -> SetMaximum(1.0);
  TCanvas * c = new TCanvas;
  ex -> Draw();
  h -> Draw("COLZTEXTSAME");

  h -> SetMarkerSize(3.0);
  TH2 * h2 = new TH2F("h2", "h2", 2, -0.5, 1.5, 2, -0.5, 1.5);
  h2 -> Fill(0.0, 0.0, 2.0);
  h2 -> Fill(0.0, 1.0, 2.5);
  h2 -> Fill(1.0, 0.0, 0.5);
  h2 -> Fill(1.0, 1.0, 1.5);
  TCanvas *c2 = new TCanvas;
  h2 -> Draw("COLZ");
  return 0;
}

void pal()
{
  const unsigned char Number = 6;
  Int_t colours[Number] = {kGreen -10, kGreen -6, kGreen + 1};
  Double_t Red[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2,};
  Double_t Green[Number] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
  Double_t Blue[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2 };
  Double_t Stops[Number] = {0.0, 0.5, 0.50001, 0.6, 0.6000001, 1.0};
  TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, 10);
  gStyle -> SetPaintTextFormat("2.2f");
  gStyle -> SetOptStat(0);

}

```

`TH2 * h` is drawn in a very distorted way:

 ![matrix](https://root-forum.cern.ch/uploads/default/original/3X/d/0/d0cfd0f8d2a2599d424a5b62fe9847c1983d75d0.png)

What could I fix?

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 11, 2021, 3:28pm UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/14 "2021-05-11T15:28:24Z")

</div>

I see that the right drawing sequence is:

```auto
  h -> Draw("COLZTEXT");
  ex -> Draw();
  h -> Draw("COLZTEXTSAME");

```

I also see that `TExec` does not execute properly lambda functions. It is yet unclear how to make TExec compatible with a standard C++ project.

---

<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 12, 2021, 6:54am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/15 "2021-05-12T06:54:25Z")

</div>

> [@Viesturs](#):
>
> I also see that `TExec` does not execute properly lambda functions

No it does not. You should use a normal C++ function.

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 17, 2021, 8:20am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/16 "2021-05-17T08:20:00Z")

</div>

I am trying to use 2 palettes by creating 2 styles:

```auto
void pal1(TStyle * style);
int multiplepalettes()
{
  TStyle * st1 = new TStyle("st1", "my style 1");
  TStyle * st2 = new TStyle("st2", "my style 2");
  pal1(st1);
  gROOT -> SetStyle("st1");
  TH2 * h1 = new TH2F("h1", "h1", 2, -0.5, 1.5, 2, -0.5, 1.5);
  h1 -> Fill(0.0, 0.0, 0.62);
  h1 -> Fill(0.0, 1.0, 0.51);

  h1 -> Fill(1.0, 0.0, 0.2);
  h1 -> Fill(1.0, 1.0, 0.7);

  TCanvas * c1 = new TCanvas;
  h1 -> Draw("COLZTEXT");
  gROOT -> SetStyle("st2");

  TH2 * h2 = new TH2F("h2", "h2", 2, -0.5, 1.5, 2, -0.5, 1.5);
  h2 -> Fill(0.0, 0.0, 2.0);
  h2 -> Fill(0.0, 1.0, 2.5);

  h2 -> Fill(1.0, 0.0, 0.5);
  h2 -> Fill(1.0, 1.0, 1.5);

  TCanvas *c2 = new TCanvas;
  h2 -> Draw("COLZ");
  return 0;
}

void pal1(TStyle *style)
{
  const unsigned char Number = 6;
  Int_t colours[10];

  Double_t Red[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2,};
  Double_t Green[Number] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
  Double_t Blue[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2 };
  Double_t Stops[Number] = {0.0, 0.5, 0.50001, 0.6, 0.6000001, 1.0};

  Int_t FI = TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, 10);
  for (unsigned char ind = 0; ind < 10; ind ++)
    colours[ind] = FI + ind;
  style -> SetPalette(10, colours);
  style -> SetPaintTextFormat("2.2f");
  style -> SetOptStat(0);
}

```

`TStyle "st2"` is supposed to use the default Root palette. However, the example doesn’t work. What could I fix?

---

<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 17, 2021, 9:26am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/17 "2021-05-17T09:26:58Z")

</div>

The palette are note stored By the style. Only one palette is available. To have several on the same plot you should use TExec,

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 17, 2021, 9:47am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/18 "2021-05-17T09:47:27Z")

</div>

In this example using `TExec` both histograms are drawn with the same palette:

```auto
void pal();
int palette()
{
  TExec * ex = new TExec("ex", "pal();");
  TH2 * h1 = new TH2F("h1", "h1", 2, -0.5, 1.5, 2, -0.5, 1.5);
  h1 -> Fill(0.0, 0.0, 2.0);
  h1 -> Fill(0.0, 1.0, 2.5);

  h1 -> Fill(1.0, 0.0, 0.5);
  h1 -> Fill(1.0, 1.0, 1.5);
  TCanvas * c1 = new TCanvas;
  h1 -> Draw("COLZ");
  ex -> Draw();
  h1 -> Draw("COLZSAME");
  TH2 * h2 = new TH2F("h2", "h2", 2, -0.5, 1.5, 2, -0.5, 1.5);
  h2 -> Fill(0.0, 0.0, 2.0);
  h2 -> Fill(0.0, 1.0, 2.5);
  h2 -> Fill(1.0, 0.0, 0.5);
  h2 -> Fill(1.0, 1.0, 1.5);
  TCanvas *c2 = new TCanvas;
  h2 -> Draw("COLZ");
  return 0;
}

void pal()
{
  const unsigned char Number = 6;
  Int_t colours[10];

  Double_t Red[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2,};
  Double_t Green[Number] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
  Double_t Blue[Number] = {0.75, 0.75, 0.5, 0.5, 0.2, 0.2 };
  Double_t Stops[Number] = {0.0, 0.5, 0.50001, 0.6, 0.6000001, 1.0};
  TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, 10);
}

```

What is wrong?

---

<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:** [May 17, 2021, 9:56am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/19 "2021-05-17T09:56:00Z")

</div>

`grep -r TExec ${ROOTSYS}/tutorials`

---

<div class="post-metadata">

**Author:** ![Viesturs](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/7cd45c/32.png) [@Viesturs](https://root-forum.cern.ch/u/Viesturs)\
**Post date:** [May 17, 2021, 10:00am UTC](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761/20 "2021-05-17T10:00:50Z")

</div>

I study the example `multipalette.C` but I find no clue what is wrong in my example.

[Next page](https://root-forum.cern.ch/t/formatting-colour-palette-with-threshold-values/44761.md?page=2)
