# TEffiency set y axis ranges

**URL:** <https://root-forum.cern.ch/t/teffiency-set-y-axis-ranges/59464>\
**Category:** ROOT\
**Tags:** python\
**Created:** [May 25, 2024, 2:09pm UTC](https://root-forum.cern.ch/t/teffiency-set-y-axis-ranges/59464 "2024-05-25T14:09:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eballabe](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eballabe/32/21846_2.png) [@eballabe](https://root-forum.cern.ch/u/eballabe)\
**Post date:** [May 25, 2024, 2:09pm UTC](https://root-forum.cern.ch/t/teffiency-set-y-axis-ranges/59464/1 "2024-05-25T14:09:29Z")

</div>

Hello,  
how can I set the Minimum and Maximum in TEffiency plots?

Tried [this](https://root-forum.cern.ch/t/set-range-y-axis-tefficiency/21296) in my python script (L1TriggerEff is an instance of TEffiency that I can draw):  
graph = L1TriggerEff.GetPaintedGraph();  
graph.SetMinimum(0;  
graph.SetMaximum(1)  
gPad.Update()

but got  
graph.SetMinimum(0);  
ReferenceError: attempt to access a null-pointer

Cheers,  
Eric

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [May 25, 2024, 3:14pm UTC](https://root-forum.cern.ch/t/teffiency-set-y-axis-ranges/59464/2 "2024-05-25T15:14:24Z")

</div>

Hi Eric,

I am sorry you are experiencing this issue.  
Could you please paste the full reproducer here (@couet)?

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![eballabe](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eballabe/32/21846_2.png) [@eballabe](https://root-forum.cern.ch/u/eballabe)\
**Post date:** [May 25, 2024, 3:44pm UTC](https://root-forum.cern.ch/t/teffiency-set-y-axis-ranges/59464/3 "2024-05-25T15:44:48Z")

</div>

Hi Danilo,

What I’m doing is retrieving already produced TEffiency plots and changing the style of the first drawn plot with a script. I could share a dummy script which makes a TEffiency plot and reproduces the issue.

> import ROOT  
> import numpy as np  
> np.random.seed(0)  
> x = np.random.uniform(0, 10, 100)  
> trigger = np.random.binomial(1, 0.5, 100) # Random trigger responses with 50% probability  
> nbins = 20  
> h\_total = ROOT.TH1F(“h\_total”, “Total Events”, nbins, 0, 10)  
> h\_triggered = ROOT.TH1F(“h\_triggered”, “Triggered Events”, nbins, 0, 10)  
> for i in range(len(x)):  
> ` __` h\_total.Fill(x[i])  
> ` __` if trigger[i]:  
> ` ____ ` h\_triggered.Fill(x[i])  
> efficiency = ROOT.TEfficiency(h\_triggered, h\_total)  
> efficiency.SetTitle(“Tefficiency Plot;Variable;Trigger Efficiency”)  
> c1 = ROOT.TCanvas(“c1”, “Tefficiency Plot”, 800, 600)  
> graph = efficiency.GetPaintedGraph();  
> graph.SetMinimum(0.1)  
> graph.SetMaximum(1.0)  
> gPad.Update()  
> efficiency.Draw(“AP”)  
> c1.Update()  
> c1.Draw()  
> c1.SaveAs(“tefficiency\_plot.png”)

I can’t do efficiency.SetMinimum(0.1) as

> AttributeError: ‘TEfficiency’ object has no attribute ‘SetMinimum’

A workaround that I found is to first plot an empty histogram (for which I can set the style as I want) and then plot all the TEffiencies with the Draw(“same”) on top of the empty histogram.

---

<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 27, 2024, 8:56am UTC](https://root-forum.cern.ch/t/teffiency-set-y-axis-ranges/59464/4 "2024-05-27T08:56:41Z")

</div>

What about:

```auto
efficiency.GetPaintedHistogram().SetMinimum()

```

?

---

<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:** [June 10, 2024, 8:57am UTC](https://root-forum.cern.ch/t/teffiency-set-y-axis-ranges/59464/5 "2024-06-10T08:57:04Z")

</div>

Closed on June 10, 2024, 8:57am UTC

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