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.
#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
I’m sorry for reviving this topic, but could you explain the reason why 0 is clipped in that example?
The comment in ratioplotOld.C says Avoid the first label (0) to be clipped., however the solution results in removing 0 and not avoiding it to be clipped (i.e. it disappears in my macro).
I indeed tried to use TRatioPlot, but it messes up with the style of my plots using CMS tdrstyle.C, so I went with the good old TPad solution. In my particular case I’m leaving a gap between the upper and ratio histograms and the gap indeed clips both 0 and top label of the ratio plot. I noticed that when I do:
canv->GetFrame()->Draw()
a border is drawn around that gap, which gave me a hint to fixed it, however I couldn’t manage to remove it or remove the fill color.
In a hope to use TRatioPlot, is there a way to use it without affecting the margins? I’m trying to find a way to avoid resetting margins by hand because part of my plots won’t have a ratio.
The plot you are trying to achieve doesn’t seem to be a standard TRatioPlot. If only part of your plot has a ratio some special tuning might be necessary. That should be seen…