ROOT logo
void surfaces() {
   //Draw 2-Dim functions
   // To see the output of this macro, click begin_html <a href="gif/surfaces.gif">here</a> end_html
   //Author: Rene Brun
   
   TCanvas *c1 = new TCanvas("c1","Surfaces Drawing Options",200,10,700,900);
   c1->SetFillColor(42);
   gStyle->SetFrameFillColor(42);
   title = new TPaveText(.2,0.96,.8,.995);
   title->SetFillColor(33);
   title->AddText("Examples of Surface options");
   title->Draw();

   pad1 = new TPad("pad1","Gouraud shading",0.03,0.50,0.98,0.95,21);
   pad2 = new TPad("pad2","Color mesh",0.03,0.02,0.98,0.48,21);
   pad1->Draw();
   pad2->Draw();
   //
   // We generate a 2-D function
   TF2 *f2 = new TF2("f2","x**2 + y**2 - x**3 -8*x*y**4",-1,1.2,-1.5,1.5);
   f2->SetContour(48);
   f2->SetFillColor(45);

   // Draw this function in pad1 with Gouraud shading option
   pad1->cd();
   pad1->SetPhi(-80);
   pad1->SetLogz();
   f2->Draw("surf4");

   // Draw this function in pad2 with color mesh option
   pad2->cd();
   pad2->SetTheta(25);
   pad2->SetPhi(-110);
   pad2->SetLogz();
   f2->Draw("surf1");
   
   //add axis titles. The titles are set on the intermediate
   //histogram used for visualisation. We must force this histogram
   //to be created, then force the redrawing of the two pads
   pad2->Update();
   f2->GetHistogram()->GetXaxis()->SetTitle("x title");
   f2->GetHistogram()->GetYaxis()->SetTitle("y title");
   f2->GetHistogram()->GetXaxis()->SetTitleOffset(1.4);
   f2->GetHistogram()->GetYaxis()->SetTitleOffset(1.4);
   pad1->Modified();
   pad2->Modified();
}
 surfaces.C:1
 surfaces.C:2
 surfaces.C:3
 surfaces.C:4
 surfaces.C:5
 surfaces.C:6
 surfaces.C:7
 surfaces.C:8
 surfaces.C:9
 surfaces.C:10
 surfaces.C:11
 surfaces.C:12
 surfaces.C:13
 surfaces.C:14
 surfaces.C:15
 surfaces.C:16
 surfaces.C:17
 surfaces.C:18
 surfaces.C:19
 surfaces.C:20
 surfaces.C:21
 surfaces.C:22
 surfaces.C:23
 surfaces.C:24
 surfaces.C:25
 surfaces.C:26
 surfaces.C:27
 surfaces.C:28
 surfaces.C:29
 surfaces.C:30
 surfaces.C:31
 surfaces.C:32
 surfaces.C:33
 surfaces.C:34
 surfaces.C:35
 surfaces.C:36
 surfaces.C:37
 surfaces.C:38
 surfaces.C:39
 surfaces.C:40
 surfaces.C:41
 surfaces.C:42
 surfaces.C:43
 surfaces.C:44
 surfaces.C:45
 surfaces.C:46
 surfaces.C:47
 surfaces.C:48
thumb