# TEfficiency with Log Scale?

**URL:** <https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694>\
**Category:** ROOT\
**Tags:** graphics, hist, root\
**Created:** [February 11, 2026, 1:29pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694 "2026-02-11T13:29:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lost\_soul\_519](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lost_soul_519/32/30431_2.png) [@lost\_soul\_519](https://root-forum.cern.ch/u/lost_soul_519)\
**Post date:** [February 11, 2026, 1:29pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/1 "2026-02-11T13:29:22Z")

</div>

Hello all,

Just wanted to check how the TEfficiency class are supposed to be drawn on a log Canvas. I am hoping I’ve done something stupid here. Here is a quick reproducer.

```auto
import ROOT
import numpy as np

xBins = np.logspace(0, 3, 10) 
yPass = np.random.normal(loc=500, scale=50, size=len(xBins)-1).astype(int)
yTotal = yPass + np.random.poisson(lam=20, size=len(xBins)-1)

hTotal = ROOT.TH1D("hTotal", "Total;Track Momentum (GeV/c);Entries", len(xBins)-1, xBins)
hPass = ROOT.TH1D("hPass", "Passed;Track Momentum (GeV/c);Entries", len(xBins)-1, xBins)

for i in range(len(xBins)-1):
    hTotal.SetBinContent(i+1, yTotal[i])
    hPass.SetBinContent(i+1, yPass[i])

c = ROOT.TCanvas()
c.SetLogx()

eff = ROOT.TEfficiency(hPass, hTotal)
eff.SetTitle("Tracking Efficiency;Track Momentum (GeV/c);Efficiency")
eff.SetMarkerStyle(20)
eff.SetLineColor(ROOT.kBlue)
eff.SetMarkerColor(ROOT.kBlue)
eff.Draw("AP")

c.Draw()

```

Without the logScale it works perfectly.  
But the minute I turn it on it breaks.  
How do I make the underlying graph aware that it is drawing on a log canvas?

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/f/5/f504f7937254e2ee1f05584953a84c63a51867a8.png)

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/4/a/4a9725a22b8682dbe4cd18b3a33a490ef69e3c08.png)

---

<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:** [February 11, 2026, 1:46pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/2 "2026-02-11T13:46:15Z")

</div>

A C++ version of your script works fine with ROOT master:

```auto
void trackingEfficiency() {
    TRandom3 rng;

    const int nBins = 9;
    std::vector<double> xBins(nBins + 1);

    double xmin = 1.0;
    double xmax = 1000.0;

    for (int i = 0; i <= nBins; ++i) {
        xBins[i] = xmin * TMath::Power(xmax / xmin, double(i) / nBins);
    }

    std::vector<int> yPass(nBins);
    std::vector<int> yTotal(nBins);

    for (int i = 0; i < nBins; ++i) {
        yPass[i] = int(rng.Gaus(500, 50));
        yTotal[i] = yPass[i] + rng.Poisson(20);
    }

    auto hTotal = new TH1D("hTotal", "Total;Track Momentum (GeV/c);Entries", nBins, &xBins[0]);
    auto hPass = new TH1D("hPass", "Passed;Track Momentum (GeV/c);Entries", nBins, &xBins[0]);

    for (int i = 0; i < nBins; ++i) {
        hTotal->SetBinContent(i + 1, yTotal[i]);
        hPass->SetBinContent(i + 1, yPass[i]);
    }

    auto c = new TCanvas("c", "Tracking Efficiency", 800, 600);
    c->SetLogx();

    auto *eff = new TEfficiency(*hPass, *hTotal);
    eff->SetTitle("Tracking Efficiency;Track Momentum (GeV/c);Efficiency");
    eff->SetMarkerStyle(20);
    eff->SetLineColor(kBlue);
    eff->SetMarkerColor(kBlue);

    eff->Draw();
}

```

 ![Screenshot 2026-02-11 at 14.41.27](https://root-forum.cern.ch/uploads/default/original/3X/b/a/ba0e10645fd0dfbc2eac1bb98a4215182efc3088.jpeg)

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [February 11, 2026, 1:46pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/3 "2026-02-11T13:46:34Z")

</div>

Try with a newer or the latest ROOT version; with the latest (6.36.08) I don’t see that issue (used your Python script).

---

<div class="post-metadata">

**Author:** ![lost\_soul\_519](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lost_soul_519/32/30431_2.png) [@lost\_soul\_519](https://root-forum.cern.ch/u/lost_soul_519)\
**Post date:** [February 11, 2026, 2:11pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/4 "2026-02-11T14:11:11Z")

</div>

Thank you @dastudillo @couet

I was already based off master which caught me by surprise since I could reproduce this in both my master build and a conda build (ROOT-6-36-06) which is why I didn’t mention my version in the above.

I did a little more digging turns out this only happen when I try to do the above plot in a notebook environment (for fine tuning) regardless of the root version.

The minute I run it as a python script the plot seems to work okay. Sorry about that should I checked this before I posted.

Thanks a lot. I just continue with as a python script instead.

P.S Here is an attachment of my notebook render if it helps.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/3/b/3ba3f424668e58ae083ff2da13e48d70aeee0626.png)

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [February 11, 2026, 2:32pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/5 "2026-02-11T14:32:04Z")

</div>

Try adding `%jsroot off`

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/a/c/ac2c1da7944a50e701d1e6ecb09a360483819bc5.png)

---

<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:** [February 11, 2026, 2:39pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/6 "2026-02-11T14:39:27Z")

</div>

I forgot to mention that I ran the script with standard graphics (option `--web=off`). When I run without this option I get the following wrong result:

 ![Screenshot 2026-02-11 at 15.36.35](https://root-forum.cern.ch/uploads/default/original/3X/c/1/c1b646b91abaae8746197d9358d4d8ddec18543a.png)

So it is clearly a problem with Web Graphics. Let’s ping @linev about it.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [February 11, 2026, 2:54pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/7 "2026-02-11T14:54:55Z")

</div>

Yes, I can reproduce the problem.

`TEfficiency` is not handled correctly by `TWebCanvas`.

Here PR which fixes the problem: [[webcanv] add TEfficiency to list of supported classes by linev · Pull Request #21249 · root-project/root · GitHub](https://github.com/root-project/root/pull/21249)

I will provide also backport to ROOT 6.38 branch

---

<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:** [February 25, 2026, 2:54pm UTC](https://root-forum.cern.ch/t/tefficiency-with-log-scale/64694/8 "2026-02-25T14:54:59Z")

</div>

Closed on February 25, 2026, 2:54pm UTC

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