# Fitting a function on top of a color map

**URL:** <https://root-forum.cern.ch/t/fitting-a-function-on-top-of-a-color-map/50567>\
**Category:** Newbie\
**Tags:** hist\
**Created:** [June 27, 2022, 1:39pm UTC](https://root-forum.cern.ch/t/fitting-a-function-on-top-of-a-color-map/50567 "2022-06-27T13:39:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xaratustra](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xaratustra/32/13212_2.png) [@xaratustra](https://root-forum.cern.ch/u/xaratustra)\
**Post date:** [June 27, 2022, 1:39pm UTC](https://root-forum.cern.ch/t/fitting-a-function-on-top-of-a-color-map/50567/1 "2022-06-27T13:39:47Z")

</div>

I have a 2D histogram which I plot as a color map, color is the quantity, horizontal axis is frequency and the vertical axis is the time. Now I see that in this color map, the quantity is changing position in a parabolic shape, so I like to fit a parabola on top of it, as a function of time and frequency.

I have done many fits with ROOT, but this is my first time trying to fit on a 2D histogram, basically not sure how to do it. Any hint, or example, is appreciated.

_ROOT Version:_ 6.22/06  
_Platform:_ osx  
_Compiler:_ PyROOT

* * *

---

<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 27, 2022, 1:44pm UTC](https://root-forum.cern.ch/t/fitting-a-function-on-top-of-a-color-map/50567/2 "2022-06-27T13:44:19Z")

</div>

[This example](https://root.cern/doc/master/fit2_8C.html) is what you are looking for.

---

<div class="post-metadata">

**Author:** ![xaratustra](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/xaratustra/32/13212_2.png) [@xaratustra](https://root-forum.cern.ch/u/xaratustra)\
**Post date:** [July 14, 2022, 4:37pm UTC](https://root-forum.cern.ch/t/fitting-a-function-on-top-of-a-color-map/50567/3 "2022-07-14T16:37:18Z")

</div>

thank you and sorry for late reply, it actually took me some time to understand the example. In fact it seems that my application is very well covered in the [next example](https://root.cern/doc/master/fit2d_8C.html) after the one you suggested.

From a 2D histogram, I can then create a `ProfileY`, which as I understood, means for every X bin, the average of Y is calculated. This is then the trend that I was looking for and can be fitted. So your answer helped solve the problem.
