// ================== PlotHeights_x.C #include void gg () { // gROOT->Reset(); // TString datdir = "../data/"; // TString fname = TString(filename); // TString file = datdir+fname; TCanvas *c = new TCanvas("c","test",0,0,1024,768); c->Divide(2,1); TGraph2D *dt = new TGraph2D("graph.dat"); Int_t n = dt->GetN(); cout << "File contains " << n << " control points" << endl; Double_t* x = dt->GetX(); Double_t* y = dt->GetY(); Double_t* z = dt->GetZ(); Double_t xmax = dt->GetXmax(); Double_t xmin = dt->GetXmin(); Double_t ymax = dt->GetYmax(); Double_t ymin = dt->GetYmin(); // What the students get c->cd(1); gPad->SetPhi(-90); // Viewpoint gPad->SetTheta(-89.99); dt->SetMarkerStyle(8); // Marker for the control points dt->SetTitle(""); dt->Draw("AP"); c->Update(); //<========== Double_t xyz[3], uv[3]; //<========== TView *view = gPad->GetView(); TText *t = new TText; t->SetTextSize(0.035); for (Int_t i=0;iGetX()[i]; xyz[1] = dt->GetY()[i]; xyz[2] = dt->GetZ()[i]; view->WCtoNDC(xyz,uv); t->DrawText(uv[0]+0.01,uv[1],Form("%g",z[i])); } // TString imagefile = "../images/"+fname+".eps"; // gPad->Print(imagefile); // Print the current pad (only) // The solution, in 3D viewed from above gStyle->SetPalette(1); Double_t contours[] = {20,40,60,80,100,120,140,160,180,200}; c->cd(2); gPad->SetPhi(0); // Viewpoint gPad->SetTheta(90); TH2D* h = dt->GetHistogram(); // Get histo interpolated between // control points in dt. h->SetContour(10,contours); // Set 10 contour levels (default is 20) h->Draw("surf2"); // Draw interpolated points as surface h->Draw("cont1 same"); // Contour the surface dt->SetTitle(""); dt->SetMarkerStyle(8); // Marker for the control points dt->Draw("p same"); // Superimpose the control points // TString imagefile = "../images/"+fname+"_solution.eps"; // gPad->Print(imagefile); // Print the current pad (only) //return c; }