# Histo plotted with the "same" option dissapear when fitting

**URL:** <https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644>\
**Category:** ROOT\
**Created:** [May 16, 2014, 7:53am UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644 "2014-05-16T07:53:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pamputt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pamputt/32/12526_2.png) [@pamputt](https://root-forum.cern.ch/u/pamputt)\
**Post date:** [May 16, 2014, 7:53am UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644/1 "2014-05-16T07:53:52Z")

</div>

Hello,  
I have plotted 5 TH1 in test.C  
The first I have plotted is the red one (hh). Then I plotted the black TH1 with the option “same”. If I choose to fit the red TH1 (via graphical tool or via command line), the result of the fit is displayed but the other TH1s (hh1, hh2, … in black) disappear.  
It is not the cas if I fit one of the black histo (the result of the fit is displayed and no TH1 is removed)  
I guess it is a bug which should be fixed.  
Thanks in advance

The problem is present in ROOT 5.34/18  
[test.C](https://root-forum.cern.ch/uploads/default/original/2X/e/e36b284f0b74cf3eec547d89fdfa184af18a4590.C) (227 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:00am UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644/2 "2014-05-16T11:00:42Z")

</div>

I do not see anything wrong with your macro. Seems to me it does what it should. It does not fit by the way.

---

<div class="post-metadata">

**Author:** ![pamputt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pamputt/32/12526_2.png) [@pamputt](https://root-forum.cern.ch/u/pamputt)\
**Post date:** [May 16, 2014, 11:22am UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644/3 "2014-05-16T11:22:09Z")

</div>

Hmmm, sorry to do not have explain very well. My macro works well.  
To reproduce what I described, do the following

```auto

```

Zoom around a peak (for example between 500 and 520)  
Click right on the red histo and select "FitPanel"  
Click on fit to fit the red histo with a Gaussian.  
The result of the fit is displayed but meanwhile the other TH1 are removed from the frame.

---

<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:33am UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644/4 "2014-05-16T11:33:06Z")

</div>

Ah ok … clear now… I think the Fit command ignore the fact there was other histogram on the plot. I will tell my colleague responsible of the fit panel to look are this.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [May 16, 2014, 1:44pm UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644/5 "2014-05-16T13:44:01Z")

</div>

Hi,

You should use the option “same”, passed as graphics option in TH1::Fit. Do for example

hh-\>Fit(“gaus”,"",“same”);

However, I see that in the FitPanel, the “Same” draw option does not work. I will fix this bug  
Thank you for posting this problem  
Lorenzo

---

<div class="post-metadata">

**Author:** ![pamputt](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pamputt/32/12526_2.png) [@pamputt](https://root-forum.cern.ch/u/pamputt)\
**Post date:** [May 16, 2014, 2:16pm UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644/6 "2014-05-16T14:16:37Z")

</div>

Hi, thank you for the answer.  
Could we imagine that the “same” option be enabled by default?  
It would be nice because it is inconvenient to lose some histos after a fit…

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [May 16, 2014, 3:12pm UTC](https://root-forum.cern.ch/t/histo-plotted-with-the-same-option-dissapear-when-fitting/17644/7 "2014-05-16T15:12:23Z")

</div>

Hi,

You are right. It is better to have the histogram redrawn on the same canvas as before by default. This has been fixed now in both 5.34 and master versions of ROOT

Lorenzo
