Histogram title

Dear experts,
I used (1) to set the position and the size of the hist title but the 2d line does not work. Indeed, when I change it, the hist title size does not change. I have root version 6.12, is that the right way to change the hist title size?
Regards

(1)
gStyle->SetOptTitle(1); // set hist title
gStyle->SetTitleSize(0.2, “t”);
gStyle->SetTitleX(0.4); //title X location
gStyle->SetTitleY(0.9); //title Y location
gStyle->SetTitleW(0.5); //title width
gStyle->SetTitleH(0.15); //title height

it works for me. Can you sent a macro we can run reproducing the problem ?

Dear Couet,
you can see the code and the root file here (1).
I also have a problem with “GetLowerRefGraph()” from TRatioPlot at line 107-108, indeed I have the error message at (2), but if I remove these line, it works fine. Do you see what is wrong?
Regards

(1)
http://calpas.web.cern.ch/calpas/plot.cc
http://calpas.web.cern.ch/calpas/hist-mc16_13TeV.root

(2)
warning: null passed to a callee that requires a non-null argument [-Wnonnull]
ratio -> GetLowerRefGraph() -> SetMinimum(-1);

You get an error right at the beginning of your macro. May be you should fix that 1st:

Warning in <TGraphAsymmErrors::Divide>: Number of graph points is different than histogram bins - 67 points have been skipped

Dear Couet,
I guess this is because some bins are empty. The binning is the same.
If I remove the ratio hist, the title hist does not reduce or increase at line 6?
I do not see what is wrong with GetLowerRefGraph(), as the line right above “SetGridlines” works fine?
Regards

Ok … your macro seems seriously wrong :frowning: … I can spend some time on it to make it better but It will take a bit of time…

Ok I edited your macro to isolate the problem. See the comments in the macro.
calbet2.C (3.9 KB)

Dear Couet,
I’m confused. If I run the code without “GetLowerRefGraph()”, it draw the ratio plots bellow the hist as expected see(1), so the drawing seems to wok fine with the Divided canvas. There is a problem when I’m calling “GetLowerRefGraph()”. For some reason it does not work? If there is a more general problem with TRatio, it should not work at all I guess. I tried in a canvas (no Divide() called and still the same issue).
Regards

(1)
image

I get:

Error in <TRatioPlot::GetLowerRefGraph>: Lower pad does not have primitives

and crash …

I think you should really fix the Warnings.

But why do I have these warning? isn’t it because of empty bins? if yes TRatio should handle properly empty bins I guess?
Regards

Did you understood why “gStyle->SetTitleSize(0.02, “t”);” does work? it’s not related to TRatio.
Regards

For me it works. Your macro gives me the following plot (when i comment all the buggy part).

May be you have something in your rootlogon.C … gROOT->ForceStyle() ?

Yes, I’m ruuning “rootstyle();” with this file (1).
Regards

(1)
http://calpas.web.cern.ch/calpas//rootstyle.cc

start root with the option “-n” to not execute the rootlogon.C and see if that fixes the problem.

Still the same. I also have the error message "Error in TRatioPlot::GetLowerRefGraph: Lower pad does not have primitives.
Regards

When you run the modified macro (with the ratio plot commented) I sent you, what plot do you get ?

If I remove “GetLowerRefGraph” I have (1). If I keep it I have the error message.
Regards

(1)
image

The the code:

   gStyle->SetTitleX(0.4); //title X location
   gStyle->SetTitleY(0.9); //title Y location
   gStyle->SetTitleW(0.5); //title width
   gStyle->SetTitleH(0.15); //title height

is working the title if bigger and shifted

No, the location is working but the size is not.
Regards

The title is a pave box. The size of the title is defined SetTitleW and SetTitleH (W and H of the box)