Logo ROOT   6.12/07
Reference Guide
draw2dopt.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// \notebook
4 /// Display the various 2-d drawing options
5 ///
6 /// \macro_code
7 ///
8 /// \author Rene Brun
9 
10 void draw2dopt()
11 {
12  gStyle->SetOptStat(0);
15  TF2 *f2 = new TF2("f2","xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
16  Double_t params[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5, 3600,-2,0.7,-3,0.3};
17  f2->SetParameters(params);
18  TH2F h2("h2","xygaus + xygaus(5) + xylandau(10)",20,-4,4,20,-4,4);
19  h2.SetFillColor(46);
20  h2.FillRandom("f2",40000);
21  TPaveLabel pl;
22 
23  //basic 2-d options
24  Float_t xMin=0.67, yMin=0.875, xMax=0.85, yMax=0.95;
25  Int_t cancolor = 17;
26  TCanvas c2h("c2h","2-d options",10,10,800,600);
27  c2h.Divide(2,2);
28  c2h.SetFillColor(cancolor);
29  c2h.cd(1);
30  h2.Draw(); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SCAT","brNDC");
31  c2h.cd(2);
32  h2.Draw("box"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"BOX","brNDC");
33  c2h.cd(3);
34  h2.Draw("arr"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"ARR","brNDC");
35  c2h.cd(4);
36  h2.Draw("colz"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"COLZ","brNDC");
37  c2h.Update();
38 
39  //text option
40  TCanvas ctext("ctext","text option",50,50,800,600);
41  gPad->SetGrid();
42  ctext.SetFillColor(cancolor);
43  ctext.SetGrid();
44  h2.Draw("text"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"TEXT","brNDC");
45  ctext.Update();
46 
47  //contour options
48  TCanvas cont("contours","contours",100,100,800,600);
49  cont.Divide(2,2);
50  gPad->SetGrid();
51  cont.SetFillColor(cancolor);
52  cont.cd(1);
53  h2.Draw("contz"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONTZ","brNDC");
54  cont.cd(2);
55  gPad->SetGrid();
56  h2.Draw("cont1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT1","brNDC");
57  cont.cd(3);
58  gPad->SetGrid();
59  h2.Draw("cont2"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT2","brNDC");
60  cont.cd(4);
61  gPad->SetGrid();
62  h2.Draw("cont3"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT3","brNDC");
63  cont.Update();
64 
65  //lego options
66  TCanvas lego("lego","lego options",150,150,800,600);
67  lego.Divide(2,2);
68  lego.SetFillColor(cancolor);
69  lego.cd(1);
70  h2.Draw("lego"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"LEGO","brNDC");
71  lego.cd(2);
72  h2.Draw("lego1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"LEGO1","brNDC");
73  lego.cd(3);
74  gPad->SetTheta(61); gPad->SetPhi(-82);
75  h2.Draw("surf1pol"); pl.DrawPaveLabel(xMin,yMin,xMax+0.05,yMax,"SURF1POL","brNDC");
76  lego.cd(4);
77  gPad->SetTheta(21); gPad->SetPhi(-90);
78  h2.Draw("surf1cyl"); pl.DrawPaveLabel(xMin,yMin,xMax+0.05,yMax,"SURF1CYL","brNDC");
79  lego.Update();
80 
81  //surface options
82  TCanvas surf("surfopt","surface options",200,200,800,600);
83  surf.Divide(2,2);
84  surf.SetFillColor(cancolor);
85  surf.cd(1);
86  h2.Draw("surf1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF1","brNDC");
87  surf.cd(2);
88  h2.Draw("surf2z"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF2Z","brNDC");
89  surf.cd(3);
90  h2.Draw("surf3"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF3","brNDC");
91  surf.cd(4);
92  h2.Draw("surf4"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF4","brNDC");
93  surf.Update();
94 }
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:628
float Float_t
Definition: RtypesCore.h:53
R__EXTERN TStyle * gStyle
Definition: TStyle.h:402
int Int_t
Definition: RtypesCore.h:41
void SetCanvasColor(Color_t color=19)
Definition: TStyle.h:318
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:346
virtual void DrawPaveLabel(Double_t x1, Double_t y1, Double_t x2, Double_t y2, const char *label, Option_t *option="")
Draw this pavelabel with new coordinates.
Definition: TPaveLabel.cxx:89
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:20
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:249
A 2-Dim function with parameters.
Definition: TF2.h:29
The Canvas class.
Definition: TCanvas.h:31
double Double_t
Definition: RtypesCore.h:55
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Definition: TStyle.cxx:1266
#define gPad
Definition: TVirtualPad.h:285