ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
surfaces.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_graphs
3 /// Draw 2-Dim functions.
4 /// \macro_image
5 /// \macro_code
6 ///
7 /// \author Rene Brun
8 
9 void surfaces() {
10  TCanvas *c1 = new TCanvas("c1","Surfaces Drawing Options",200,10,700,900);
11  c1->SetFillColor(42);
13  TPaveText *title = new TPaveText(.2,0.96,.8,.995);
14  title->SetFillColor(33);
15  title->AddText("Examples of Surface options");
16  title->Draw();
17 
18  TPad *pad1 = new TPad("pad1","Gouraud shading",0.03,0.50,0.98,0.95,21);
19  TPad *pad2 = new TPad("pad2","Color mesh",0.03,0.02,0.98,0.48,21);
20  pad1->Draw();
21  pad2->Draw();
22  //
23  // We generate a 2-D function
24  TF2 *f2 = new TF2("f2","x**2 + y**2 - x**3 -8*x*y**4",-1,1.2,-1.5,1.5);
25  f2->SetContour(48);
26  f2->SetFillColor(45);
27 
28  // Draw this function in pad1 with Gouraud shading option
29  pad1->cd();
30  pad1->SetPhi(-80);
31  pad1->SetLogz();
32  f2->Draw("surf4");
33 
34  // Draw this function in pad2 with color mesh option
35  pad2->cd();
36  pad2->SetTheta(25);
37  pad2->SetPhi(-110);
38  pad2->SetLogz();
39  f2->SetLineWidth(1);
40  f2->SetLineColor(5);
41  f2->Draw("surf1");
42 
43  //add axis titles. The titles are set on the intermediate
44  //histogram used for visualisation. We must force this histogram
45  //to be created, then force the redrawing of the two pads
46  pad2->Update();
47  f2->GetHistogram()->GetXaxis()->SetTitle("x title");
48  f2->GetHistogram()->GetYaxis()->SetTitle("y title");
49  f2->GetHistogram()->GetXaxis()->SetTitleOffset(1.4);
50  f2->GetHistogram()->GetYaxis()->SetTitleOffset(1.4);
51  pad1->Modified();
52  pad2->Modified();
53 }
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title Offset is a correction factor with respect to the "s...
Definition: TAttAxis.cxx:245
virtual void SetLineWidth(Width_t lwidth)
Definition: TAttLine.h:57
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF2.cxx:216
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
virtual void SetTheta(Double_t theta=30)
Definition: TPad.h:350
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
Definition: TPaveText.cxx:160
virtual void Update()
Update pad.
Definition: TPad.cxx:2721
virtual TH1 * GetHistogram() const
Return a pointer to the histogram used to vusualize the function.
Definition: TF1.cxx:1274
TVirtualPad * cd(Int_t subpadnumber=0)
Set Current pad.
Definition: TPad.cxx:514
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:367
virtual void Draw(Option_t *option="")
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1192
virtual void SetLineColor(Color_t lcolor)
Definition: TAttLine.h:54
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
The most important graphics class in the ROOT system.
Definition: TPad.h:46
virtual void SetPhi(Double_t phi=30)
Definition: TPad.h:351
TAxis * GetYaxis()
Definition: TH1.h:320
A 2-Dim function with parameters.
Definition: TF2.h:33
The Canvas class.
Definition: TCanvas.h:48
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:35
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TF2.cxx:872
virtual void SetLogz(Int_t value=1)
Set Lin/Log scale for Z.
Definition: TPad.cxx:5324
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
Definition: TNamed.cxx:152
void Modified(Bool_t flag=1)
Definition: TPad.h:407
TAxis * GetXaxis()
Definition: TH1.h:319