Logo ROOT  
Reference Guide
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// Draw 2-Dim functions.
6/// \macro_image
7/// \macro_code
9/// \author Rene Brun
11void 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();
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);
27 // Draw this function in pad1 with Gouraud shading option
28 pad1->cd();
29 pad1->SetPhi(-80);
30 pad1->SetLogz();
31 f2->Draw("surf4");
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");
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");
50 pad1->Modified();
51 pad2->Modified();
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
Definition: TAttAxis.cxx:293
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
The Canvas class.
Definition: TCanvas.h:23
virtual TH1 * GetHistogram() const
Return a pointer to the histogram used to visualise the function Note that this histogram is managed ...
Definition: TF1.cxx:1574
A 2-Dim function with parameters.
Definition: TF2.h:29
virtual void SetContour(Int_t nlevels=20, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TF2.cxx:901
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF2.cxx:241
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
Definition: TH1.h:320
TAxis * GetYaxis()
Definition: TH1.h:321
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
The most important graphics class in the ROOT system.
Definition: TPad.h:26
void SetLogz(Int_t value=1) override
Set Lin/Log scale for Z.
Definition: TPad.cxx:5958
void Update() override
Update pad.
Definition: TPad.cxx:2855
void SetPhi(Double_t phi=30) override
Definition: TPad.h:352
void Modified(Bool_t flag=1) override
Definition: TPad.h:414
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
Definition: TPad.cxx:603
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
Definition: TPad.cxx:1299
void SetTheta(Double_t theta=30) override
Definition: TPad.h:351
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:21
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:183
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:234
return c1
Definition: legend1.C:41