Superimpose 2D histogram and function

Hi,

How to present the result of the fit of 2D histogram by 2d function in a clear way?

I have the histogram hpeak2 and function f2. I’d like to plot them together to get the idea about the quality of the fit.

If I plot them separatly it’s ok:
root [6] hpeak2->Draw(“lego”)
root [8] f2->Draw(“surf”)

the maximum of the function is correspond to 3000 * 100

If I try to do like this:
root [9] hpeak2->Draw(“lego”)
root [10] f2->Draw(“surf same”)

I got the plot left-down on the ntslab01.na.infn.it/test/c1.gif
which is completly missleading (the function is visibly higher his real position)

If I try to use the color information and do it like this
root [12] hpeak2->Draw(“colZ”)
root [13] f2->Draw(“cont1 same”)

I got right-down plot which didn’t makes the situation more clear since as you see the top of the function is red - scaled incorrectly to 5000 insteas of 3000 as it should be.

Inside ntslab01.na.infn.it/test/test2.root I saved hpeak2, f2 and c1.

Regards
Valeri

put the maximum of the function equal to the maximum of the histogram and you will be able to superimpose them correcty.

f2->SetMaximum(500000)
hpeak2->Draw(“lego”)
f2->Draw(“surf same”)

also you might try:

hpeak2->Draw(“lego”)
f2->Draw(“cont same”)

[quote=“couet”]put the maximum of the function equal to the maximum of the histogram and you will be able to superimpose them correcty.

f2->SetMaximum(500000)
hpeak2->Draw(“lego”)
f2->Draw(“surf same”)

also you might try:

hpeak2->Draw(“lego”)
f2->Draw(“cont same”)[/quote]

why not f2->SetMaximum(500123) ?
I do not understand why I need to do this manual normalizations if I just like to plot histogram and a function in the same coordinate system together in the same way as it’s typically works in 1-dimentional case

VT

I put 5000000 as an example because looking at the plot it was close to it, but you are right you should put the real maximum of the histogram.
The 3D representaitions are drawn in some normalized space that is why the option “same” doesn’t work as well as for 1D plot. But you are right, in principal we should be able to do that sort of adjustments automatically. I started to do it in case of the “box” option: it now takes care of the previous plot(s) when option “same” is used. The same kind of thing should maybe dome also for 3D plots.