As you can see, the range on the lower pad has been set as specified by SetRangeUser. But the SetNdivisions method does not seem to have been applied. Also, calling r.GetLowerPad().Update() or c.Update() does not seem to do anything.
Is there a workaround to change the number of divisions on the lower pad?
IMO the behaviour of SetNdivisions should be the same as for SetRangeUser above. It should be easy to change the number of axis divisions to avoid overlapping axis labels as in the plot above.
{
auto C = new TCanvas("C", "A ratio example");
auto h1 = new TH1D("h1","h1",21,-5,5);
auto h2 = new TH1D("h2","h2",21,-5,5);
h1->FillRandom("gaus",10000);
h2->FillRandom("gaus",10000);
auto r = new TRatioPlot(h1, h2);
r->Draw();
r->GetLowYaxis()->SetNdivisions(2);
r->GetLowerRefYaxis()->SetRangeUser(0, 2);
}
The code does indeed seem to work in Cint. It’s only in pyROOT where the behaviour isn’t as expected. I did manage to get it to work by JITing a wrapper function: