# Trying to change the box width in a TH3

**URL:** <https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005>\
**Category:** Newbie\
**Created:** [April 20, 2020, 10:51pm UTC](https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005 "2020-04-20T22:51:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliangb](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/juliangb/32/21448_2.png) [@juliangb](https://root-forum.cern.ch/u/juliangb)\
**Post date:** [April 20, 2020, 10:51pm UTC](https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005/1 "2020-04-20T22:51:20Z")

</div>

Hello,

I’d like to make a TH3 using the option BOX but with the box size fixed. To do this I tried to boost each bin “heigth” to a value from where the box seemed to have its volume fixed, like shown in the first picture. But I only achieved this by editing the macros after compiling my code.

 ![BoostZ3DfromMacros](https://root-forum.cern.ch/uploads/default/original/3X/0/0/00997dba796c09934a6d2b7c1152f3d9b75ce927.png)

When I try to do it directly from my code (using this [ZOffset3D.cc](https://root-forum.cern.ch/uploads/short-url/L9S7Eu3Gc6glVhX3VBCfLnAxwO.cc) (422 Bytes) ), it returns the next graphic, “resetting” the scale. I also tried adding one extra bin, un-boosted, so that the scale changed to what it looked like in the first graph, but that didn’t work.

 ![BoostZ3D](https://root-forum.cern.ch/uploads/default/original/3X/a/7/a7f8d057b32e7cec6c9a518d1d10366271969080.png)

I’d appreciate your help with this problem.

If by the other hand there’s a way to fix the TH3 using the box function, that would also be really helpful.

Thanks in advance to you all.

ROOT Version: 6.14/04  
Platform: Ubuntu

---

<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:** [April 21, 2020, 7:29am UTC](https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005/2 "2020-04-21T07:29:49Z")

</div>

The size of the boxes is proportional to the bin content.

---

<div class="post-metadata">

**Author:** ![juliangb](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/juliangb/32/21448_2.png) [@juliangb](https://root-forum.cern.ch/u/juliangb)\
**Post date:** [April 21, 2020, 12:51pm UTC](https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005/3 "2020-04-21T12:51:04Z")

</div>

I assumed that would be the case.

But when a bin has enough content, the box seems to have its sized fixed, as seen in the first image, so as I said I boosted all bin contents to that value but when I execute it, the palette/width scale is not the same as when I do it manually from the macro.

---

<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:** [April 21, 2020, 2:44pm UTC](https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005/4 "2020-04-21T14:44:24Z")

</div>

What is the TH3 you are using ? you only posted the macro which adds a constant to all the bins.

---

<div class="post-metadata">

**Author:** ![juliangb](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/juliangb/32/21448_2.png) [@juliangb](https://root-forum.cern.ch/u/juliangb)\
**Post date:** [April 21, 2020, 4:09pm UTC](https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005/5 "2020-04-21T16:09:44Z")

</div>

This is the main code: [Many3DHistograms.cc](https://root-forum.cern.ch/uploads/short-url/6h0dxEXNPYZVma5VJfksymGsgB1.cc) (1.5 KB)  
(the line 44 is commented so that it doesn’t boost the content then)

This is the macro: [TH3BOX.C](https://root-forum.cern.ch/uploads/short-url/ukSULEHy6Oo7GpYHZmuF6G6yDdI.C) (8.4 KB) . It is edited manually to boost the histogram content (for example, ` h__2->SetBinContent(245,1+30);`, here the `+30` is the manual boost I wanted)

---

<div class="post-metadata">

**Author:** ![juliangb](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/juliangb/32/21448_2.png) [@juliangb](https://root-forum.cern.ch/u/juliangb)\
**Post date:** [April 21, 2020, 11:49pm UTC](https://root-forum.cern.ch/t/trying-to-change-the-box-width-in-a-th3/39005/6 "2020-04-21T23:49:12Z")

</div>

Solved it!

Just had to add two lines to the ZOffset3D code, this is the new one: [ZOffset3D.cc](https://root-forum.cern.ch/uploads/short-url/8H5VRvKvP41018OrzqSWg01SPJ3.cc) (634 Bytes)

First, I added the `h->SetMinimum(0)` line at the end, which solved the scale issue. But that also filled all the bins to a “volume” z0, even the ones which were unfilled before, so I had to ask to make the boost only on bins which weren’t empty before.

Thank you for your help!
