Beautifing curves in TRatioPlot

Hi there, I’m trying to plot two pseudorapidity historgrams stacked over each other and thier ratio right below in the same canvas. I went through different topics and figured out “TRatioPlot” for my need. It does the exact thing I want but the issue is I can’t beautify the resultant plot. Such as:

  1. Adding legend.
  2. Adding latex text.
  3. Change the drawing style of second curve.
  4. Plot ratio of log(y-axis) of these two plots.

I tried different ways for the ratio plots but I was facing different errors like irregular entries and other problems. At last, this macro runs perfectly for my need but I want to atleast label the curves.
If anyone knows how to do the above things in TRatioPlot, it’d be really helpful for me.

Thanking you in advance,

test2.c (1.5 KB)
c1.pdf (22.4 KB)

For access to the “internal parts” and the drawing options, see the TRatioPlot class reference (and its method descriptions therein).

For instance add the legend on the upper pad you cand do:

void ratioplot1() {
   auto c1 = new TCanvas("c1", "A ratio example");
   auto h1 = new TH1D("h1", "h1", 50, 0, 10);
   auto h2 = new TH1D("h2", "h2", 50, 0, 10);
   auto f1 = new TF1("f1", "exp(- x/[0] )");
   f1->SetParameter(0, 3);
   h1->FillRandom("f1", 1900);
   h2->FillRandom("f1", 2000);
   h2->Scale(1.9 / 2.);
   auto rp = new TRatioPlot(h1, h2);
   c1->SetTicks(0, 1);
   rp->GetUpperPad()->BuildLegend(); // Legend in upper pad


You can to the same on the lower pad.

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