# Option "same" in TH2, or "nostack" in THStack

**URL:** <https://root-forum.cern.ch/t/option-same-in-th2-or-nostack-in-thstack/17640>\
**Category:** ROOT\
**Created:** [May 15, 2014, 5:08pm UTC](https://root-forum.cern.ch/t/option-same-in-th2-or-nostack-in-thstack/17640 "2014-05-15T17:08:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ann](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@ann](https://root-forum.cern.ch/u/ann)\
**Post date:** [May 15, 2014, 5:08pm UTC](https://root-forum.cern.ch/t/option-same-in-th2-or-nostack-in-thstack/17640/1 "2014-05-15T17:08:10Z")

</div>

Dear Rooters,

I attempted to plot more TH2D histograms (histo2D\_1 … histo2D\_n) with LEGO1 option on the same graph, but without stacking their bin contents. In other words, I just want the largest bin content to “stick out” among them. I tried two methods,

(1) Put all TH2D\* histo2D\_N into a THStack\* stack, and use stack-\>(“LEGO1 NOSTACK”)  
The NOSTACK option has no effect (it keeps stacking them).

(2) I used the SAME option,  
histo2D\_1-\> Draw(“LEGO1”) …  
histo2D\_n-\> Draw(“SAME”)  
This gives a funny result, since it actually draws the new plot on top of the previous ones, so they are seen only in the background, the 3-d-effect is ruined. Also the Z scale is individual for each plot.

Later I found someone reported a similar thing with NOSTACK option in 2D, but it was an old post.

I could think of a way to solve this by manipulating the bin contents (checking the bins one by one for all graphs, deleting the bin content in each histogram except for the largest one…), but before I do it I wanted to ask: is there anything implemented already in the latest root to do this?

(If not, and if we are allowed to vote for some new features, I think it would be really useful to have a NOSTACK+LEGO1 option in 2D for THStack 🙂 I understand that NOSTACK gives an ambiguous result when the COLZ option is turned on for example, but with LEGO this would be very useful in many cases)

Thanks in advance!

Anna  
[same\_TH2.eps](https://root-forum.cern.ch/uploads/default/original/2X/d/d0aab67e727e2d14e45fe01e90e648fd13c21655.eps) (310 KB)  
[nostack\_TH2.eps](https://root-forum.cern.ch/uploads/default/original/2X/9/983352c732beeaf1eb5886cb1083017916ed931d.eps) (83 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 16, 2014, 11:12am UTC](https://root-forum.cern.ch/t/option-same-in-th2-or-nostack-in-thstack/17640/2 "2014-05-16T11:12:10Z")

</div>

The NOSTAK option works only for 1D histogram stacks.  
The 2D histogram stack are always stack.  
In you case I would not use stack. You should make a 2D histogram where each bin  
contains the maximum (for that bin) of you histograms collection.

---

<div class="post-metadata">

**Author:** ![ann](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@ann](https://root-forum.cern.ch/u/ann)\
**Post date:** [May 16, 2014, 12:38pm UTC](https://root-forum.cern.ch/t/option-same-in-th2-or-nostack-in-thstack/17640/3 "2014-05-16T12:38:18Z")

</div>

Thanks. Yeah, actually there has to be N number of modified histograms in order to ensure the different colors;  
(One needs to check all bins, choose the histogram which has the largest value there, delete the bin content in every other histograms)

But this is only good for the visual effect, it cannot be used for analysis afterwards.

To give an example: Lets’ assume you have two 2D histogram data coming from 2 equipment, measuring the same thing, but giving slightly different results. What I want to know is _not_ the addition (STACK) of the values in each bin content, but their average, for instance. On the other hand, I would like to visualize them with different colors on the same graph. So what I would need is:

– plot the two histo on the same graph without stacking, but preserving all bin contents for analysis.  
(Visually only the histo with the largest bin content is seen for each bin, but the others are there, too)

– fit something on the surface of the collection, like you would fit on a TMultigraph.

The only solution I know of doing this is:

– Make a THStack, just for the visual effect as explained above, but not use it for physics  
– Fit on another (invisible) histogram, which is constructed from the average of the bin contents of all histograms.

I personally would not like to do this, I rather give up the multicolors and do the second step only, it’s too dangerous to fit on something you don’t see. In this case, however, I don’t see at all where the data is coming from. So this is not so good either.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 16, 2014, 1:24pm UTC](https://root-forum.cern.ch/t/option-same-in-th2-or-nostack-in-thstack/17640/4 "2014-05-16T13:24:24Z")

</div>

May be you can have a look at:

> [@Locate like command](https://root-forum.cern.ch/t/locate-like-command/65/1):
>
> Hi everybody, I’m just learning how to use root interface. There is a way to have a graphical integral of an histogram (like the PAW command “locate -i”) ?? cheers Paolo Zuccon.
