How to overlay one histogram on another?

I have 2 histogram and can’t overlay one histogram on two. Only add to one another.


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


guess you talk about drawing:

h1->Draw();
h2->Draw("same");

for details consult the docu:
https://root.cern/doc/v620/classTHistPainter.html#HP060

Otto

If you need to compute common X and Y scales for the two histograms, you can also use THStack.

My histograms is in different files and I open them through ROOT Object browser

I tried to use the THStack, but it stacks them, not overlays them.

your_stack->Draw("NOSTACK");

And how can I use it fron browser?

As soon as you deal with more complex objects like THStack the browser is quickly not efficient and limits the amount of ROOT functionalities you can use (C++ programming
, etc …) . You can put the option “NOSTACK” in the “Draw Option” field … but that’s not a really good solution.

if you do it the simple way with option “same”
you can do it with the TBrowser:
Select the first file and draw the hist1 (double click)
Then select the second file, press with the right mouse
your desired hist2 and choose DrawClone.
A widget will show up, fill in the option same (without the “”)
and press ok

Otto

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