Axes labels and titles on TPads

Hi,

Using example ratioplot.C, I have managed to create two pads within a single canvas: the “top” pad with a THStack+TH1F (histplot) and the “bottom” pad (ratioplot) with the ratio of the two. The hist plot is just as I want it, and in fact looks great.

The problem is with the ratioplot. I have coded it in the exact same way as the histplot, but I cannot seem to change the label or title sizes (which is very peculiar, since I followed the same procedure in both cases). The ratioplot axes titles don’t even appear.

In a nutshell, I want to know how I can change the ratioplot axes’ text size. It would also be great if I could change the number y-axis divisions, e.g. -1 to 1 with major ticks at {-1,0,1} and minor ticks at 0.25 intervals.

Thanks in advance.

Best,
Vince.

P.S. The SetXXX{Size,Offset} in my code are obscure, I know. I was messing around with different values to see if anything changed (nothing did).
Plotter_TopCR.cxx (8.61 KB)

It is difficult to test your macro because we do not have the data files…
Either you provide them (or reduced versions of them) or you provide a running, reduced, version of your macro reproducing your problem.

[quote=“couet”]It is difficult to test your macro because we do not have the data files…
Either you provide them (or reduced versions of them) or you provide a running, reduced, version of your macro reproducing your problem.[/quote]

Sorry about that…attached is a MWE. Lines 79-84 are what I want to accomplish, but these lines do nothing (as far as I can tell).

Thanks,
Vince.
ratiotest.C (4.35 KB)

these lines should be:


[..]

 TH1 *frame= gPad->DrawFrame(200., 0.5, 2000., 1.5);
 
[...]

  frame->GetXaxis()->SetLabelSize(5.2323);
  frame->GetXaxis()->SetTitle("m(lljj) [GeV]");
  frame->GetXaxis()->SetTitleOffset(1);
  frame->GetYaxis()->SetTitle("Data / Bkg");
  frame->GetYaxis()->SetTitleSize(80);

[...]

That did it – thanks a lot!

Now, I am wondering why I couldn’t have used the same method as I did for the top pad. Can you provide a bit of explanation?

  • Vince

Your histogram on the bottom is drawn with the option “SAME”… which means that the histogram is drawn in a pre-existing plot. That pre-existing plot produces the axes. And that’s on that plot you should act to add titles. In your case that pre-existing plot is drawn by DrawFrame.

Got it – cheers!

  • Vince