# THStack with RDataFrame

**URL:** <https://root-forum.cern.ch/t/thstack-with-rdataframe/39291>\
**Category:** Newbie\
**Tags:** graphics, rdataframe\
**Created:** [May 6, 2020, 6:04pm UTC](https://root-forum.cern.ch/t/thstack-with-rdataframe/39291 "2020-05-06T18:04:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eballabe](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eballabe/32/21846_2.png) [@eballabe](https://root-forum.cern.ch/u/eballabe)\
**Post date:** [May 6, 2020, 6:05pm UTC](https://root-forum.cern.ch/t/thstack-with-rdataframe/39291/1 "2020-05-06T18:05:00Z")

</div>

Hi, I’m trying to draw a simple THStack using the new RDataFrame class. The problem is that I get the histograms drawn as points, while I would like to have them drawn as line and filled with colors.

```
c125_25 = ROOT.TCanvas("c1", "c1", 0, 0, 800, 600)

df_top = ROOT.RDataFrame("ttbar", "/mypath/bkgade.root")
df_singletop = ROOT.RDataFrame("Wt", "/mypath/bkgade.root")

hsingletop = df_singletop.Histo1D("BDT_DeltaM100","Weight")
htop = df_top.Histo1D("BDT_DeltaM100","Weight")

hsingletop.SetFillColor(kOrange-9)
htop.SetFillColor(kAzure+1)

hsingletop.GetXaxis().SetLimits(0.,1.)
htop.GetXaxis().SetLimits(0.,1.)

hs = ROOT.THStack("","")    
hs.Add(hsingletop.GetPtr())
hs.Add(htop.GetPtr())
hs.Draw("F")
```

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [May 6, 2020, 8:02pm UTC](https://root-forum.cern.ch/t/thstack-with-rdataframe/39291/2 "2020-05-06T20:02:10Z")

</div>

Hi @eballabe,  
welcome to the ROOT forum!

To be 100% sure I understand the problem: can you get the THStack drawn as you want if RDataFrame is _not_ involved?

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![eballabe](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eballabe/32/21846_2.png) [@eballabe](https://root-forum.cern.ch/u/eballabe)\
**Post date:** [May 6, 2020, 8:22pm UTC](https://root-forum.cern.ch/t/thstack-with-rdataframe/39291/3 "2020-05-06T20:22:57Z")

</div>

Hi @eguiraud,  
I just solved the issue (nothing to do with RDataFrame). I just changed the last line:

```
hs.Draw("HIST")

```

as I read here:

> [@THStack not filling histograms with color](https://root-forum.cern.ch/t/thstack-not-filling-histograms-with-color/24577):
>
> 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? Mo…

Thanks for the reply!  
Eric
