i got Error in <THistPainter::PaintInit>: Cannot set Y axis to log scale when i did the following:
(try to uncomment the SetRangeUser() line to see the error.
Without knowing what obj1 and obj2 are, we cannot tell, so it’s better to post code that can be run and that reproduces the problem.
The following works:
import ROOT as r
import math
c = r.TCanvas("c","c",800,800)
c.SetLogy()
n = 20
g1 = r.TGraph(n)
g2 = r.TGraph(n)
for i in range (n):
g1.SetPoint(i,i,10*math.sin(i*0.1+0.2)-4)
g2.SetPoint(i,i,5*math.sin(i*0.1+0.2))
g1.Draw("AC*")
g2.Draw("C*")
c.Draw()
even swapping the drawing order of g1 and g2 (note that g1 has some negative y values, and it still works with log, at least on root 6.26/10). And by the way, you don’t need that c.Draw(), as g1 and g2 are already drawn on c in this case, given your code.
Well, my example works as expected, as I mentioned, so it may be a problem with your objects. Can you post the full code that shows your issue? If my example doesn’t work for you then you have a different problem, maybe try resintalling root, or a newer version.
Ok, i have rephrased my question… after finding that this is something to do with the SetRangeUser(). try to reproduce with the corresponding line commented out / commented.
void ng() {
auto f1 = new TF1("f1","landau");
f1->SetParameters(1e6,2,3);
auto h1 = new TH1D("h1","h1",200,0,3);
h1->SetLineColor(kRed);
auto h2 = new TH1D("h2","h2",200,0,3);
h1->FillRandom("f1",1000000);
h2->FillRandom("landau",1000000);
auto c = new TCanvas("c","c",800,800);
c->SetLogy();
h1->Draw();
h1->GetYaxis()->SetRangeUser(0.01,7500);
h2->Draw("same");
}