// Create, Draw and fit a TGraph2DErrors void macro4(){ gStyle->SetPalette(kBird); const double e = 0.3; const int nd = 500; TRandom3 my_random_generator; TF2 f2("f2", "1000*(([0]*sin(x)/x)*([1]*sin(y)/y))+200", -6,6,-6,6); f2.SetParameters(1,1); TGraph2DErrors dte(nd); // Fill the 2D graph double rnd, x, y, z, ex, ey, ez; for (Int_t i=0; iGetXaxis(); TAxis *Yaxis = f2c->GetYaxis(); TAxis *Zaxis = f2c->GetZaxis(); Xaxis->SetTitle("X Title"); Xaxis->SetTitleOffset(1.5); Yaxis->SetTitle("Y Title"); Yaxis->SetTitleOffset(1.5); Zaxis->SetTitle("Z Title"); Zaxis->SetTitleOffset(1.5); dte.DrawClone("P0 Same"); // Make the x and y projections auto c_p= new TCanvas("ProjCan", "The Projections",1000,400); c_p->Divide(2,1); c_p->cd(1); dte.Project("x")->Draw(); c_p->cd(2); dte.Project("y")->Draw(); }