Lego plot fit

Hello rooters

I’m doing a lego plot and a fit.
The fit parameters seem to be calculated correctly but the fit-function is somehow displayed wrong.
Below there’s a complete example that can just be copied and started:

[code]void test2() {
TCanvas *c=new TCanvas(“c”,“name”,600,600);
TH2F *histo2=new TH2F(“histo2”,“name”,20,0,20,20,0,20);
TF2 *dist=new TF2(“dist”,"[0]+[1]*x+[2]*y",0,20,0,20);
dist->SetParameters(1,0,0);
histo2->FillRandom(“dist”,40000);
histo2->SetMinimum(0);

TF2 *fit2=new TF2(“fit”,"[0]+[1]*x+[2]*y",0,20,0,20);
histo2->Fit(fit2);

histo2->Draw(“lego”);
fit2->SetLineColor(4);
fit2->SetLineWidth(1);
fit2->Draw(“surfsame”);
}[/code]

I would expect I plane more or less parallel to the x-y-plane at a hight of about 100.

Thanks for your help!

Cheers, Christian

The option “same” with lego and surface plots does not work unless the legos and surfaces have exactly the same x y and z axis. Plot the fit alone and you will see that you get what you expected.

Thanks a lot. I works fine if a plot the fit alone…

Cheers, Christian