Home | News | Documentation | Download

TRatioPlot with TimeDisplay

Dear all,

I’d like to draw the ratio plot with time units.
As attached file below, I created a simple example modified from ‘$ROOTSYS/tutorials/graphs/timeonaxis2.C.’
Actually, only 4 lines add to the original as below,

TH1F h2 =(TH1F)h1->Clone();
h2->Draw(“same”);
//auto rp =new TRatioPlot(h1,h2);
//rp->Draw();

In the case without the ratio plot, the time units draw well.
@couet In the other case, when I activate lines for the ratio plot,
the time units don’t draw.

Would you tell me how to do it?

Best regards,
Hide

_ROOT Version: 6.20/04
_Platform: CentOS Linux release 7.8.2003 (Core)
_Compiler: GCC 4.9.3

timeonaxis2.C (1.0 KB)

Hello Hide,

@couet is indeed the right person to ask, but this week, he’s on vacation. Can you ping us here in this thread on Monday?

If you are ready to endure some pain, you can try to play with (it will display “time units”):
${ROOTSYS}/tutorials/hist/ratioplotOld.C

Thanks for your quick reply!

I merged two examples (ratioplotOld.C and timeonaxis2.C).
Actually as attached file below, I realize the ratio plot with time units.

But this method is complicated (there are many steps to draw the plot),
so I’d like to use TRatioPlot class.

Is there any other way with TRatioPlot class.

Best regards,
Hide

ratioplotOld.C (3.9 KB)

Why don’t you use GetLowerRefXaxis from TRatioplot and change it into a time axis ?

Have you tried it?

No. just an idea.

I did and I then advised to try the old tutorial. :wink:

Thanks for your suggestion!

But your mentioned method does not work as attached file below. Is there any other way?

Best regards,
Hide
timeonaxis2.C (1.2 KB)

Yes @Wile_E_Coyote tried and it doesn’t not work. Try what he suggested with the old ratio plot command.

Thanks for your quick reply!
I got it. I will use the old ratio plot command.

Best regards,
Hide

@couet Reusing the ${ROOTSYS}/tutorials/hist/ratioplotOld.C with different histograms is a bit painful. I would like to propose the following improvement:

#if ROOT_VERSION_CODE >= ROOT_VERSION(6,8,0)
   // Avoid the first label (0) to be clipped.
   TAxis *axis = h1->GetYaxis();
   axis->ChangeLabel(1, -1, -1, -1, -1, -1, " ");
   axis->SetLabelFont(43); // Absolute font size in pixel (precision 3)
   axis->SetLabelSize(15);
#else
   // Do not draw the Y axis label on the upper plot and redraw a small
   // axis instead, in order to avoid the first label (0) to be clipped.
   h1->GetYaxis()->SetLabelSize(0.);
   TGaxis *axis = new TGaxis( -5, 20, -5, 220, 20,220,510,"");
   axis->SetLabelFont(43); // Absolute font size in pixel (precision 3)
   axis->SetLabelSize(15);
   axis->Draw();
#endif

ratioplotOld.C (3.5 KB)

In ratioplotOld.C ? may be you can create a PR with that ?

You macro does not work on Mac:

root [0] 
Processing ratioplotOld.C...
In file included from input_line_12:1:
/Users/couet/git/couet-root/tutorials/hist/ratioplotOld.C:33:42: error: invalid digit '8' in octal constant
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,08,00)
                                         ^
root [1] 

On the way: