Compare several histograms with TRatioPlot


I’d like to compare several histograms to a reference histogram and I started doing this using TRatioPlot (which I find a great update in the latest ROOT versions).

I see that the TRatioPlot only supports two histograms in the constructor:

TRatioPlot (TH1 *h1, TH1 *h2, Option_t *option="pois")

so I tried to define a TRatioPlot for each histogram I want to compare to the reference but, as far as I understand, I can’t Draw more than one TRatioPlot on the same Canvas, e.g. (I am using pyroot):


doesn’t show superimposed TRatioPlots as it would do if ratio1 and ratio2 were histograms.

Is this expected? Is there a known workaround?


ROOT Version (e.g. 5.34/36):
Working on lxplus

You can retrieve the first top and bottom canvases of the 1st ratio plot cd to them and plot the histogram you want on top using option same.

Hi @couet
thanks for the feedback, it is useful!
I guess I am also missing another piece of info: I also want to retrieve the histograms so that I can plot them on the (top and bottom) canvases. Let me give you an example:

ratio1 = TRatioPlot(h1,h0)
ratio2 = TRatioPlot(h2,h0)

In the end I’d like to have h0, h1 and h2 displayed on the top canvas and h1/h0 and h2/h0 displayed on the bottom canvas.


Some idea:

ratio2 = TRatioPlot(h2,h0)
TGraph *g = ratio2->GetLowerRefGraph();
ratio1 = TRatioPlot(h1,h0)
1 Like

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