ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
draw2dopt.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// Display the various 2-d drawing options
4 ///
5 /// \macro_code
6 ///
7 /// \author Rene Brun
8 
9 {
10  gStyle->SetOptStat(0);
11  gStyle->SetPalette(1);
14  TF2 *f2 = new TF2("f2","xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
15  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};
16  f2->SetParameters(params);
17  TH2F h2("h2","xygaus + xygaus(5) + xylandau(10)",20,-4,4,20,-4,4);
18  h2.SetFillColor(46);
19  h2.FillRandom("f2",40000);
20  TPaveLabel pl;
21 
22  //basic 2-d options
23  Float_t xMin=0.67, yMin=0.875, xMax=0.85, yMax=0.95;
24  Int_t cancolor = 17;
25  TCanvas c2h("c2h","2-d options",10,10,800,600);
26  c2h.Divide(2,2);
27  c2h.SetFillColor(cancolor);
28  c2h.cd(1);
29  h2.Draw(); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SCAT","brNDC");
30  c2h.cd(2);
31  h2.Draw("box"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"BOX","brNDC");
32  c2h.cd(3);
33  h2.Draw("arr"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"ARR","brNDC");
34  c2h.cd(4);
35  h2.Draw("colz"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"COLZ","brNDC");
36  c2h.Update();
37 
38  //text option
39  TCanvas ctext("ctext","text option",50,50,800,600);
40  gPad->SetGrid();
41  ctext.SetFillColor(cancolor);
42  ctext.SetGrid();
43  h2.Draw("text"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"TEXT","brNDC");
44  ctext.Update();
45 
46  //contour options
47  TCanvas cont("contours","contours",100,100,800,600);
48  cont.Divide(2,2);
49  gPad->SetGrid();
50  cont.SetFillColor(cancolor);
51  cont.cd(1);
52  h2.Draw("contz"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONTZ","brNDC");
53  cont.cd(2);
54  gPad->SetGrid();
55  h2.Draw("cont1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT1","brNDC");
56  cont.cd(3);
57  gPad->SetGrid();
58  h2.Draw("cont2"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT2","brNDC");
59  cont.cd(4);
60  gPad->SetGrid();
61  h2.Draw("cont3"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT3","brNDC");
62  cont.Update();
63 
64  //lego options
65  TCanvas lego("lego","lego options",150,150,800,600);
66  lego.Divide(2,2);
67  lego.SetFillColor(cancolor);
68  lego.cd(1);
69  h2.Draw("lego"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"LEGO","brNDC");
70  lego.cd(2);
71  h2.Draw("lego1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"LEGO1","brNDC");
72  lego.cd(3);
73  gPad->SetTheta(61); gPad->SetPhi(-82);
74  h2.Draw("surf1pol"); pl.DrawPaveLabel(xMin,yMin,xMax+0.05,yMax,"SURF1POL","brNDC");
75  lego.cd(4);
76  gPad->SetTheta(21); gPad->SetPhi(-90);
77  h2.Draw("surf1cyl"); pl.DrawPaveLabel(xMin,yMin,xMax+0.05,yMax,"SURF1CYL","brNDC");
78  lego.Update();
79 
80  //surface options
81  TCanvas surf("surfopt","surface options",200,200,800,600);
82  surf.Divide(2,2);
83  surf.SetFillColor(cancolor);
84  surf.cd(1);
85  h2.Draw("surf1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF1","brNDC");
86  surf.cd(2);
87  h2.Draw("surf2z"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF2Z","brNDC");
88  surf.cd(3);
89  h2.Draw("surf3"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF3","brNDC");
90  surf.cd(4);
91  h2.Draw("surf4"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF4","brNDC");
92  surf.Update();
93 }
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:432
virtual void FillRandom(const char *fname, Int_t ntimes=5000)
Fill histogram following distribution in function fname.
Definition: TH2.cxx:592
float Float_t
Definition: RtypesCore.h:53
R__EXTERN TStyle * gStyle
Definition: TStyle.h:423
int Int_t
Definition: RtypesCore.h:41
void SetCanvasColor(Color_t color=19)
Definition: TStyle.h:339
void SetFrameFillColor(Color_t color=1)
Definition: TStyle.h:367
TH2D * h2
Definition: fit2dHist.C:45
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:32
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
tuple pl
Definition: first.py:10
A 2-Dim function with parameters.
Definition: TF2.h:33
The Canvas class.
Definition: TCanvas.h:48
void lego()
Definition: lego.C:4
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:1252
#define gPad
Definition: TVirtualPad.h:288
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition: TStyle.cxx:1445