# TEffiency set y axis ranges

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

Tried this in my python script (L1TriggerEff is an instance of TEffiency that I can draw):
graph = L1TriggerEff.GetPaintedGraph();
graph.SetMinimum(0;
graph.SetMaximum(1)

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

Cheers,
Eric

Hi Eric,

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

Cheers,
D

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)
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.

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