# How to see each 1D fitted form from a 2D fitted histogram?

**URL:** <https://root-forum.cern.ch/t/how-to-see-each-1d-fitted-form-from-a-2d-fitted-histogram/55418>\
**Category:** ROOT\
**Tags:** roofit, python, hist, root\
**Created:** [June 23, 2023, 7:28pm UTC](https://root-forum.cern.ch/t/how-to-see-each-1d-fitted-form-from-a-2d-fitted-histogram/55418 "2023-06-23T19:28:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SAYAN\_CHATTERJEE](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayan_chatterjee/32/21843_2.png) [@SAYAN\_CHATTERJEE](https://root-forum.cern.ch/u/SAYAN_CHATTERJEE)\
**Post date:** [June 23, 2023, 7:28pm UTC](https://root-forum.cern.ch/t/how-to-see-each-1d-fitted-form-from-a-2d-fitted-histogram/55418/1 "2023-06-23T19:28:36Z")

</div>

Hello Experts,

I have a 2-dimensional histogram(x,y) and fitted it with a 2-dimensional fitting function (x, y). And the fitting is working. But now I want to see how the 2D fitting passes in each dimension, like x and y, for a range of y and x, respectively, like a 1-dimension fitted form of a 2-dimension fitted histogram.  
It is kind of I want to make a 1D projection of a 2D fitted histogram. I mean, the projection is simultaneously on the histogram and the 2D fitted function.

Could someone please help?

Thanks & Regards,  
Sayan Chatterjee

---

<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:** [June 26, 2023, 6:56am UTC](https://root-forum.cern.ch/t/how-to-see-each-1d-fitted-form-from-a-2d-fitted-histogram/55418/2 "2023-06-26T06:56:47Z")

</div>

I guess @moneta can help you

---

<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:** [June 26, 2023, 2:25pm UTC](https://root-forum.cern.ch/t/how-to-see-each-1d-fitted-form-from-a-2d-fitted-histogram/55418/3 "2023-06-26T14:25:16Z")

</div>

Hi,  
You can use the function `TH2::ProjectX/Y` to perform the projection of your histogram. The fitted function is not automatically projected, but you can use the trick to transform in an histogram (using `TF2::GetHistogram` and then project the function as well.  
If you are unable to do this, I could send you an example code (but it will take a bit of time)

Best,

Lorenzo

---

<div class="post-metadata">

**Author:** ![SAYAN\_CHATTERJEE](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sayan_chatterjee/32/21843_2.png) [@SAYAN\_CHATTERJEE](https://root-forum.cern.ch/u/SAYAN_CHATTERJEE)\
**Post date:** [June 30, 2023, 7:23am UTC](https://root-forum.cern.ch/t/how-to-see-each-1d-fitted-form-from-a-2d-fitted-histogram/55418/4 "2023-06-30T07:23:22Z")

</div>

Dear Moneta,

Many thanks for the help. It would be very helpful for me if you could send a piece of code.

Regards,  
Sayan

---

<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:** [July 14, 2023, 7:23am UTC](https://root-forum.cern.ch/t/how-to-see-each-1d-fitted-form-from-a-2d-fitted-histogram/55418/5 "2023-07-14T07:23:49Z")

</div>

Closed on July 14, 2023, 7:23am UTC

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