# THStack not filling histograms with color

**URL:** <https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577>\
**Category:** ROOT\
**Created:** [April 27, 2017, 2:46pm UTC](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577 "2017-04-27T14:46:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Vannerom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/65b543/32.png) [@David\_Vannerom](https://root-forum.cern.ch/u/David_Vannerom)\
**Post date:** [April 27, 2017, 2:46pm UTC](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577/1 "2017-04-27T14:46:28Z")

</div>

Dear all,

I am encountering a very peculiar esthetic issue: I have 8 histograms stacked with a THStack and drawn, each filled with its own color:

histo1-\>SetLineColor(1);  
histo1-\>SetFillColor(1);  
…

I then stack them, and draw them and everything works fine. Then I realized I actually need to weight those histograms when filling them:

histo1-\>Fill(variable, weight1);  
…

And now, with weighted histos, the stack only draws the histograms line and not the “interior”. How can I solve this?

More information: I tried to wieght the histograms with weight=1, and it then plots them properly, with the plain color inside each histo. I also tried to do histo-\>Sumw2() but when I do this, it never draws the plain color, even if the weight is =1 or if there are no weights.

Thanks a lot for your help!

---

<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 27, 2017, 3:00pm UTC](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577/2 "2017-04-27T15:00:07Z")

</div>

Can you provide a small script reproducing this problem ?

---

<div class="post-metadata">

**Author:** ![David\_Vannerom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/65b543/32.png) [@David\_Vannerom](https://root-forum.cern.ch/u/David_Vannerom)\
**Post date:** [April 27, 2017, 3:26pm UTC](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577/3 "2017-04-27T15:26:48Z")

</div>

Here is a working script. The bool variable “weights” decides whether weights are applied or not on the histograms. You see immediately the difference on the plot.[debug.C](https://root-forum.cern.ch/uploads/default/original/2X/6/6ec39c010d345dc5debfc03a1a564238dc73758e.C) (5.9 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:** [April 28, 2017, 6:54am UTC](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577/4 "2017-04-28T06:54:42Z")

</div>

Do:

```auto
  histo_stack->Draw("hist");

```

Explanation [here](https://root.cern/doc/master/classTHistPainter.html#HP01a).

---

<div class="post-metadata">

**Author:** ![David\_Vannerom](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/65b543/32.png) [@David\_Vannerom](https://root-forum.cern.ch/u/David_Vannerom)\
**Post date:** [April 28, 2017, 9:29am UTC](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577/5 "2017-04-28T09:29:49Z")

</div>

It worked, thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 12, 2017, 9:40am UTC](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577/6 "2017-05-12T09:40:47Z")

</div>

Closed on May 12, 2017, 9:40am UTC

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