How to merge two histograms generated with RDataFrame

Dear Users,

I am trying to draw a histogram from data obtained from two columns m1 and m2 in a RDF object df. For this I run:

hist1 = df.Histo1D(("", "", 10, 0, 100),"m1")
hist2 = df.Histo1D(("", "", 10, 0, 100),"m2")

which generates the histograms for each column, but now I would like to “merge” both histograms into one, and I am unsure on how to do this. Would anyone know how to proceed in this case?
Any help would be appreciated!

I guess you mean a THStack.

1 Like

THStack will allow you to draw them together, each histogram being kept as such. If you want a new histogram being the sum of the two use Add().

1 Like

As a side note, once RDataFrame produces the histograms, what you get are (pointers to) standard ROOT histograms (TH1Ds, to be precise: ROOT: TH1D Class Reference ), and you can play with them independently of RDataFrame.


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