# TRatioPlot with TimeDisplay

**URL:** <https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927>\
**Category:** Newbie\
**Created:** [June 16, 2020, 1:39am UTC](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927 "2020-06-16T01:39:13Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 9, 2022, 1:09pm UTC](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927/26 "2022-02-09T13:09:51Z")

</div>

Ok, what’s wrong with that plot (except the not very nice Y axis) ?

---

<div class="post-metadata">

**Author:** ![diemort](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@diemort](https://root-forum.cern.ch/u/diemort)\
**Post date:** [February 9, 2022, 1:20pm UTC](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927/27 "2022-02-09T13:20:33Z")

</div>

I was trying to understand what is that white area filling the gap between the pads and possibly remove it or make it transparent.

As I said, the frame draw puts borders, but I don’t see a way to access it.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 9, 2022, 1:32pm UTC](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927/28 "2022-02-09T13:32:09Z")

</div>

> [@diemort](#):
>
> I was trying to understand what is that white area filling the gap between the pads and possibly remove it

The [original example](https://root.cern/doc/master/ratioplotOld_8C.html) has no white area. Just start from it.

---

<div class="post-metadata">

**Author:** ![diemort](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@diemort](https://root-forum.cern.ch/u/diemort)\
**Post date:** [February 9, 2022, 2:10pm UTC](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927/29 "2022-02-09T14:10:46Z")

</div>

Maybe I wasn’t clear. The point is that I _do_ want a gap between the pads, but without clipped labels in the y-axes. I see that `TRatioPlot` does the trick without clipping the numbers in the y-axes, so I was trying to achieve the same using the old recipe.

If I remove the `TAxis` in the `ratioplotOld.C` I see that the numbers are clipped, which is expected because the pads are one next to another.

 ![testold_nogap](https://root-forum.cern.ch/uploads/default/original/3X/0/8/08400410d0dc0659cd237f19742de6107585fe83.png)

I tried to add a gap between the pads, i.e., pad1 with y=[0.3,1.0] and pad2 with y=[0,0.2], but no margin is left at the top/bottom of the pads to accommodate the first/last y-axis labels.

 ![testold](https://root-forum.cern.ch/uploads/default/original/3X/9/b/9ba44b6620346f718d3c21ac271ac7c5deb8a043.png)

It could be that the top/bottom margins are set to zero, so I tried to increase it in `canv->Divide(...)`, but no effect is seen.

I’m trying to understand what happens in this area between the pads and why `TRatioPlot` doesn’t have such effect.

Cheers, Gustavo

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 9, 2022, 3:08pm UTC](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927/30 "2022-02-09T15:08:49Z")

</div>

```auto
void ratioplotOldGap( ) {
   // Define two gaussian histograms. Note the X and Y title are defined
   // at booking time using the convention "Hist_title ; X_title ; Y_title"
   TH1F *h1 = new TH1F("h1", "Two gaussian plots and their ratio;x title; h1 and h2 gaussian histograms", 100, -5, 5);
   TH1F *h2 = new TH1F("h2", "h2", 100, -5, 5);
   h1->FillRandom("gaus");
   h2->FillRandom("gaus");

   // Define the Canvas
   TCanvas *c = new TCanvas("c", "canvas", 800, 800);

   // Upper plot will be in pad1
   TPad *pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0);
   pad1->SetBottomMargin(0.03); // Upper and lower plot are not joined
   pad1->SetGridx(); // Vertical grid
   pad1->Draw(); // Draw the upper pad: pad1
   pad1->cd(); // pad1 becomes the current pad
   h1->SetStats(0); // No statistics on upper plot
   h1->Draw(); // Draw h1
   h2->Draw("same"); // Draw h2 on top of h1

   TAxis *axisy = h1->GetYaxis();
   axisy->SetLabelFont(43); // Absolute font size in pixel (precision 3)
   axisy->SetLabelSize(15);
   TAxis *axisx = h1->GetXaxis();
   axisx->SetLabelSize(0.);

   // lower plot will be in pad
   c->cd(); // Go back to the main canvas before defining pad2
   TPad *pad2 = new TPad("pad2", "pad2", 0, 0.05, 1, 0.3);
   pad2->SetTopMargin(0);
   pad2->SetBottomMargin(0.2);
   pad2->SetGridx(); // vertical grid
   pad2->Draw();
   pad2->cd(); // pad2 becomes the current pad

   // Define the ratio plot
   TH1F *h3 = (TH1F*)h1->Clone("h3");
   h3->SetLineColor(kBlack);
   h3->SetMinimum(0.8); // Define Y ..
   h3->SetMaximum(1.35); // .. range
   h3->Sumw2();
   h3->SetStats(0); // No statistics on lower plot
   h3->Divide(h2);
   h3->SetMarkerStyle(21);
   h3->Draw("ep"); // Draw the ratio plot

   // h1 settings
   h1->SetLineColor(kBlue+1);
   h1->SetLineWidth(2);

   // Y axis h1 plot settings
   h1->GetYaxis()->SetTitleSize(20);
   h1->GetYaxis()->SetTitleFont(43);
   h1->GetYaxis()->SetTitleOffset(1.55);

   // h2 settings
   h2->SetLineColor(kRed);
   h2->SetLineWidth(2);

   // Ratio plot (h3) settings
   h3->SetTitle(""); // Remove the ratio title

   // Y axis ratio plot settings
   h3->GetYaxis()->SetTitle("ratio h1/h2 ");
   h3->GetYaxis()->SetNdivisions(505);
   h3->GetYaxis()->SetTitleSize(20);
   h3->GetYaxis()->SetTitleFont(43);
   h3->GetYaxis()->SetTitleOffset(1.55);
   h3->GetYaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
   h3->GetYaxis()->SetLabelSize(15);

   // X axis ratio plot settings
   h3->GetXaxis()->SetTitleSize(20);
   h3->GetXaxis()->SetTitleFont(43);
   h3->GetXaxis()->SetTitleOffset(1);
   h3->GetXaxis()->SetLabelFont(43); // Absolute font size in pixel (precision 3)
   h3->GetXaxis()->SetLabelSize(15);
}

```

 ![Screenshot 2022-02-09 at 16.08.16](https://root-forum.cern.ch/uploads/default/original/3X/0/a/0a19e8161181d61c7173fb3fdcfb946be40caa86.png)

---

<div class="post-metadata">

**Author:** ![diemort](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/8dc957/32.png) [@diemort](https://root-forum.cern.ch/u/diemort)\
**Post date:** [February 9, 2022, 3:29pm UTC](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927/31 "2022-02-09T15:29:42Z")

</div>

Nice, thanks a lot.

[Previous page](https://root-forum.cern.ch/t/tratioplot-with-timedisplay/39927.md?page=1)
