How to change y axis range while using logarithmic scale on RooPlot

Dear root experts,
I want the maximum value of y axis to be the value 1.2*max value of the plot and use logarithmic scale at the same time but it does not seem to work,when i comment gPad->SetLogy(); it works.I use root version 6.30/04 .My code for the fitting plot is

TCanvas c_B = new TCanvas(“c_B”, " model 0 fit on Bgk only data");
RooPlot frame_B = output_BDT.frame();
double yma = gPad->GetFrame()->GetY2();
frame_B->GetYaxis()->SetLimits(0.1,1.2
yma);
// gPad->SetLogy();
data_B->plotOn(frame_B);
model_0.plotOn(frame_B);
model_0.paramOn(frame_B);
model_0.plotOn(frame_B, LineColor(kRed),Components(“tt_pdf”));
model_0.plotOn(frame_B, LineColor(kGreen),Components(“dy_pdf”));
RooCurve
curve_0 = dynamic_cast<RooCurve*>(frame_B->getObject(1));
curve_0->GetYaxis()->SetRangeUser(0.1,1.2*yma);
frame_B->Draw();

So without gPad->SetLogy(); i get a margin left at the top but when using log scale it is not done
without log scale
nolog.pdf (14.6 KB)
and with log scale
logscale.pdf (14.7 KB)
Do you have anything to suggest?
Thank you in advance.
Artemis

Hello @ataxeidi,
welcome to the ROOT forum!
I suggest you to try using SetRangeUser instead of SetLimits. Notice that, when using the log scale, SetRangeUser(min, max) will set your axis limits at min, max and not log(min), log(max), so you may want to set your upper bound as c*yma, properly setting the value of c according to your log range.
I hope it helps.
Cheers,
Monica

Dear Monica,
Thanks for your reply.When i use SetRangeUser(1,TMath::Log(1.2*yma)) i get
Error in THistPainter::PaintInit: Cannot set Y axis to log scale
and this appears :
out.pdf (12.7 KB)
I do not understand, since i set the range from 1 and above and not a zero or negative value.

Could you provide a code snippet to reproduce your error? I don’t get any error when using SetRangeUser in a log scale

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