# Problem with the stacking/scaling(?) histogram output after peak matching

**URL:** <https://root-forum.cern.ch/t/problem-with-the-stacking-scaling-histogram-output-after-peak-matching/53379>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [January 31, 2023, 11:18pm UTC](https://root-forum.cern.ch/t/problem-with-the-stacking-scaling-histogram-output-after-peak-matching/53379 "2023-01-31T23:18:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thegame](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/e495f1/32.png) [@thegame](https://root-forum.cern.ch/u/thegame)\
**Post date:** [January 31, 2023, 11:18pm UTC](https://root-forum.cern.ch/t/problem-with-the-stacking-scaling-histogram-output-after-peak-matching/53379/1 "2023-01-31T23:18:30Z")

</div>

Hi all, I’m trying to match six histogram peaks with a reference histogram (i=2) and try to plot them in the same frame with THStack.  
the scaling factor is calculated in this way,

```auto
for (int i = 0; i < 6; i++) {
    if (i == 2) { // reference histogram  
      factor[i] = 1;
      continue;
    }
    int maxBin = hist[i]->GetMaximumBin();
    factor[i] = hist[2]->GetBinContent(maxBin) / hist[i]->GetBinContent(maxBin);
    hist[i]->Scale(factor[i]);
  }

```

this part works well as well as the rest of the plotting routine. However, in the stacked output, only the reference histogram is coming with ‘------’ rest are kind of **discrete/point ‘+’** like markers although, in the legend box, it shows a line with a dot for ALL SIX histo. **(figure attached for reference)**. I have tried to vary the bin number etc. but the problem still persists.

Any suggestions to fix this? Thanks!

 ![F7icanodespeakmatched](https://root-forum.cern.ch/uploads/default/original/3X/4/3/43fbaa983e56066b8f39105f3afd0ae5f2336e0f.png)

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [February 1, 2023, 7:01am UTC](https://root-forum.cern.ch/t/problem-with-the-stacking-scaling-histogram-output-after-peak-matching/53379/2 "2023-02-01T07:01:21Z")

</div>

When you scale them, their draw style defaults to showing errors. So draw them with the “hist” option to avoid that; e.g. `h->Draw("hist")`.  
[https://root.cern/doc/master/classTHistPainter.html#HP01a](https://root.cern/doc/master/classTHistPainter.html#HP01a)
