# TGraph2D Palette : Fix a value to a color

**URL:** <https://root-forum.cern.ch/t/tgraph2d-palette-fix-a-value-to-a-color/28668>\
**Category:** ROOT\
**Created:** [April 13, 2018, 12:35am UTC](https://root-forum.cern.ch/t/tgraph2d-palette-fix-a-value-to-a-color/28668 "2018-04-13T00:35:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ricfregian](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ricfregian/32/19149_2.png) [@ricfregian](https://root-forum.cern.ch/u/ricfregian)\
**Post date:** [April 13, 2018, 12:35am UTC](https://root-forum.cern.ch/t/tgraph2d-palette-fix-a-value-to-a-color/28668/1 "2018-04-13T00:35:13Z")

</div>

* * *

ROOT Version 5.34/36  
Platform, compiler gcc version 4.9.3 (GCC)

* * *

I’m plotting many TGraph2D plots using “colz”. However for each plot the value I’m interested in changes its color in the palette (because the Palette range is changing). How can I fix a value to a color in the palette ?

---

<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:** [April 13, 2018, 4:09am UTC](https://root-forum.cern.ch/t/tgraph2d-palette-fix-a-value-to-a-color/28668/2 "2018-04-13T04:09:12Z")

</div>

I guess you should be able to enforce the same “z-range” for all your 2D graphs. For each of them call:

```auto
SomeTGraph2D->SetMinimum(MyMinimum);
SomeTGraph2D->SetMaximum(MyMaximum);

```

> [@Same color palette range for several TH3 drawn with glcolz](https://root-forum.cern.ch/t/same-color-palette-range-for-several-th3-drawn-with-glcolz/18625/5):
>
> I once applied a “brutal fix” to such a problem. I modified all relevant histograms destroying two bins: MyHisto-\>SetBinContent(1, 1, MyMinimum); MyHisto-\>SetBinContent(MyHisto-\>GetNbinsX(), MyHisto-\>GetNbinsY(), MyMaximum);

---

<div class="post-metadata">

**Author:** ![ricfregian](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ricfregian/32/19149_2.png) [@ricfregian](https://root-forum.cern.ch/u/ricfregian)\
**Post date:** [April 16, 2018, 1:05am UTC](https://root-forum.cern.ch/t/tgraph2d-palette-fix-a-value-to-a-color/28668/3 "2018-04-16T01:05:33Z")

</div>

Wile\_E\_Coyote I enforced the same “z-range” for all my 2D graphs and it worked.  
Thanks !

---

<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:** [April 30, 2018, 1:05am UTC](https://root-forum.cern.ch/t/tgraph2d-palette-fix-a-value-to-a-color/28668/4 "2018-04-30T01:05:36Z")

</div>

Closed on April 30, 2018, 1:05am UTC

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