Double_t Bidim(Double_t *x, Double_t *par){ // Gaussian bidim with 45deg inclination Double_t sqrt2=0.707106; Double_t arg1=0; Double_t arg2=0; Double_t fitval=0; arg1 = x[0]*sqrt2 + x[1]*sqrt2; arg2 = (-x[0]*sqrt2 + x[1]*sqrt2)/2; fitval = TMath::Exp(-0.5*arg1*arg1)*TMath::Exp(-0.5*arg2*arg2); return fitval; } Double_t fitf(Double_t *x, Double_t *par) { Double_t arg = 0; Double_t fitval = par[1]*x[0]+par[0]; return fitval; } void Doplot() { TH2F *plot1 = new TH2F("plot1","",100,-6,6,100,-6,6);//grid1 for the plots TH2F *plot2 = new TH2F("plot2","",300,-6,6,100,-2,2);//grid2 for the plots TF2 *mybidim = new TF2("bidim",Bidim,-3,3,-3,3,1);//bidim to plot TF1 *myline = new TF1("myline",fitf,-3,3,2);//line going through major axis myline->SetParameters(0,-1); mybidim->SetContour(4); c1 = new TCanvas("c1","",300,10,600,700); c1.Draw(); plot1.Draw(); mybidim->Draw("same"); myline->Draw("same"); c2 = new TCanvas("c2","",300,10,600,700); c2.Draw(); plot2.Draw(); mybidim->Draw("same"); myline->Draw("same"); }