Attempt to add histograms with different axis limits

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.18/04
Platform: Debian 10.4
Compiler: gcc (Debian 8.3.0-6) 8.3.0

Hi, I’m trying to Add two TH1D histograms to each other. As far as I have understood, the syntax

hist1.Add(hist1, hist2)

should do the job using PYROOT as long as the bin number and the Xaxis limits are the same and I have the method working in one of my scripts.

In another script, however, I get the error message << Info in TH1D::Add: Attempt to add histograms with different axis limits - trying to use TH1::Merge>>.

Unfortunately, I can’t post a minimal script here, but I will outline what I’ve done to try and get the histograms to add without error message:

  • Checked the type of histo and it’s <class ‘ROOT.TH1D’> for both histos.

  • Checked the number of bins via the Methods histo.GetXaxis().GetFirst() and histo.GetXaxis().GetLast(). For both histos, I get a bin number N= 1027298 .

  • Checked the Xaxis values for the first and the last bins, and they agree for both histograms hist1 and hist2 to
    t_begin_histo: 0.00022629975367420164
    t_end_histo: 256.8239702002463

          t_begin_histo = histo.GetBinCenter(first_bin_histo) 
          t_end_histo   = histo.GetBinCenter(last_bin_histo) 

Do you have any other suggestions of what I could check to eliminate the error?

Thanks for your help.

I think there was a numerical issue when checking the compatibility of the two histograms in older ROOT version. It should be fixed in 6.22, can you please try with that version ?
If there is still a problem, can you post the two histograms and the code showing the problem ?
Thank you


okay, this would make sense. Don’t have time to upgrade at the moment, but I’ll try with 6.22 soonish and let you know if the error persists.

Sounds good. In case this is the bug affecting 6.18, but version >= 6.20 are fine

You can maybe just add the patch of the fixing PR,


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