Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
surfaces.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphs
3 /// \notebook
4 /// Draw 2-Dim functions.
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Rene Brun
10 
11 void surfaces() {
12  TCanvas *c1 = new TCanvas("c1","Surfaces Drawing Options",200,10,700,900);
13  TPaveText *title = new TPaveText(.2,0.96,.8,.995);
14  title->AddText("Examples of Surface options");
15  title->Draw();
16 
17  TPad *pad1 = new TPad("pad1","Gouraud shading",0.03,0.50,0.98,0.95);
18  TPad *pad2 = new TPad("pad2","Color mesh",0.03,0.02,0.98,0.48);
19  pad1->Draw();
20  pad2->Draw();
21  //
22  // We generate a 2-D function
23  TF2 *f2 = new TF2("f2","x**2 + y**2 - x**3 -8*x*y**4",-1,1.2,-1.5,1.5);
24  f2->SetContour(48);
25  f2->SetFillColor(45);
26 
27  // Draw this function in pad1 with Gouraud shading option
28  pad1->cd();
29  pad1->SetPhi(-80);
30  pad1->SetLogz();
31  f2->Draw("surf4");
32 
33  // Draw this function in pad2 with color mesh option
34  pad2->cd();
35  pad2->SetTheta(25);
36  pad2->SetPhi(-110);
37  pad2->SetLogz();
38  f2->SetLineWidth(1);
39  f2->SetLineColor(5);
40  f2->Draw("surf1");
41 
42  //add axis titles. The titles are set on the intermediate
43  //histogram used for visualisation. We must force this histogram
44  //to be created, then force the redrawing of the two pads
45  pad2->Update();
46  f2->GetHistogram()->GetXaxis()->SetTitle("x title");
47  f2->GetHistogram()->GetYaxis()->SetTitle("y title");
48  f2->GetHistogram()->GetXaxis()->SetTitleOffset(1.4);
49  f2->GetHistogram()->GetYaxis()->SetTitleOffset(1.4);
50  pad1->Modified();
51  pad2->Modified();
52 }