# Change z-axis limits of a 2D TEfficiency graph

**URL:** <https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099>\
**Category:** Newbie\
**Created:** [March 22, 2021, 1:39am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099 "2021-03-22T01:39:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![keom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/e68b1a/32.png) [@keom](https://root-forum.cern.ch/u/keom)\
**Post date:** [March 22, 2021, 1:39am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099/1 "2021-03-22T01:39:22Z")

</div>

Hello,

I am making a 2D TEfficiency plot and I would like the range of the z-axis (on the color palette) to be from 0 to 1.2. I tried to use SetMinimum and SetMaximum but they wouldn’t work as ‘TEfficiency’ object has no attribute ‘SetMaximum’. Is there a way to do this?

Thank you,  
Carry

---

<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:** [March 22, 2021, 7:57am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099/2 "2021-03-22T07:57:14Z")

</div>

TEfficiency does not have a `GetHistogram` either. But it has [CreateHistogram](https://root.cern/doc/master/classTEfficiency.html#a1233e6b24c18bacc8cf69821b1dfd598) which returns a \*TH2 on which, I guess, you can call `SetMaximum` and `SetMinimum` to change the Z axis range. I let @moneta confirm.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 22, 2021, 8:33am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099/3 "2021-03-22T08:33:44Z")

</div>

Hi,  
For changing the limits of the plotted 2D TEfficiency object, you can call `CreateHistogram` but then you need to draw that objecty. Otherwise, after having called `TEfficiency::Draw()`, you can call `TEfficiency::GetPaintedHistogram()` to get a pointer to the histogram that is painted and afterwards you can change its attributes as you wish.

Lorenzo

---

<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:** [March 22, 2021, 8:40am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099/4 "2021-03-22T08:40:41Z")

</div>

> [@moneta](#):
>
> TEfficiency::GetPaintedHistogram()

Thanks @moneta I missed that one. And I should have find it as you already answered this question on the forum : [Set range y axis TEfficiency](https://root-forum.cern.ch/t/set-range-y-axis-tefficiency/21296)  
Sorry.  
BTW: I see that “GetPaintedHistogram” has no help. I agree the name of the function is explicit enough but may be we can had some example showing how to set the min and max. Like in the previous post.

---

<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:** [March 22, 2021, 8:57am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099/5 "2021-03-22T08:57:01Z")

</div>

BTW. It also seems a good idea to explain when (for what) to use [TEfficiency::GetPaintedGraph](https://ad6ceab62cbe2505c726c07b049ace605) versus [TEfficiency::GetPaintedHistogram](https://root.cern.ch/doc/master/classTEfficiency.html#aaa6958348083ff35c0ee17bc8801af25).

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [March 22, 2021, 9:14am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099/6 "2021-03-22T09:14:50Z")

</div>

It is documented in [Tefficiency::Paint()](https://root.cern.ch/doc/master/classTEfficiency.html#ad84a3deda47a2e617a1dd54da1593161), we should maybe add a link to there from the documentation of `TEfficiency::GetPaintedHistogram`

Lorenzo

---

<div class="post-metadata">

**Author:** ![keom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/e68b1a/32.png) [@keom](https://root-forum.cern.ch/u/keom)\
**Post date:** [March 22, 2021, 9:30am UTC](https://root-forum.cern.ch/t/change-z-axis-limits-of-a-2d-tefficiency-graph/44099/7 "2021-03-22T09:30:14Z")

</div>

It works. Thank you guys!
