How to force TRatioPlot to keep the same label

Dear experts,
I made a ratio plot with TRatioPlot but it does not keep the same label as you can see here (*). Do you know how I can ask it to keep the same label? The code is here (**).

before ratio:

after ratio:

complete code here:

I cannot run your macro because the root is missing. Could you provide a small example reproducing the problem. It seems the ratio part of the plot ignores te fact the initial histogram had alphanumeric labels.

Dear Couet,
you can run it now. Please let me know if you need something else.

Indeed you removed the path of the root files. but still I do not have the files and therefore I get the same kind of error.

The root files are here:

can’t you see them?


Yes I see them. I will check.

I see that the ratio part of the plot ignores te fact the initial histogram had alphanumeric labels. It is not implemented.

Ok, thank you. So how can I do it?


I see you are drawing the ratio plots in a loop with option hist same…
I think that will mess up the plots. Can you try to do only one ratio plot ?
Not in a loop …

I made an array of ratio hitograms, then I loop

over this array to plot separately each ratio hist in a

canvas. I removed the “same” option, but I still do

not have the right label.


I would like to access the histogram of the ratio hist (not the graph), is it possible? If yes would CalculationMode(kDivideHist) allow me to do that? If yes how/where can I use it? Indeed, once I’ve access the histogram, I can set the x label myself with SetLabelSize.

I am afraid that the alphanumeric labels histogram do not work with the current implementation of TRatioPlot.

   TFile *f = new TFile("r1.root");
   TH1D *h1 = (TH1D*) f->Get("ee/cutflow");
   TH1D *h2 = (TH1D*) f->Get("ee/cutflow_Loose");

   TCanvas *c = new TCanvas();
   TRatioPlot *rp = new TRatioPlot(h1, h2);

I guess you should go back to the old way

It is not possible to access the histogram?


All the getters for TRatioPlot are listed here:

Dear Couet,

ok, thank you for your help.


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