Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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_image
7/// \macro_code
8///
9/// \author Rene Brun
10
11void draw2dopt()
12{
16 TF2 *f2 = new TF2("f2","xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
17 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};
18 f2->SetParameters(params);
19 auto h2 = new TH2F("h2","xygaus + xygaus(5) + xylandau(10)",20,-4,4,20,-4,4);
20 h2->SetFillColor(46);
21 h2->FillRandom("f2",40000);
22 TPaveLabel pl;
23
24 //basic 2-d options
25 Float_t xMin=0.67, yMin=0.875, xMax=0.85, yMax=0.95;
26 Int_t cancolor = 17;
27 auto c2h = new TCanvas("c2h","2-d options",10,10,800,600);
28 c2h->Divide(2,2);
29 c2h->SetFillColor(cancolor);
30 c2h->cd(1);
31 h2->Draw(); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SCAT","brNDC");
32 c2h->cd(2);
33 h2->Draw("box"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"BOX","brNDC");
34 c2h->cd(3);
35 h2->Draw("arr"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"ARR","brNDC");
36 c2h->cd(4);
37 h2->Draw("colz"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"COLZ","brNDC");
38 c2h->Update();
39
40 //text option
41 auto ctext = new TCanvas("ctext","text option",50,50,800,600);
42 gPad->SetGrid();
43 ctext->SetFillColor(cancolor);
44 ctext->SetGrid();
45 h2->Draw("text"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"TEXT","brNDC");
46 ctext->Update();
47
48 //contour options
49 auto cont = new TCanvas("contours","contours",100,100,800,600);
50 cont->Divide(2,2);
51 gPad->SetGrid();
52 cont->SetFillColor(cancolor);
53 cont->cd(1);
54 h2->Draw("contz"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONTZ","brNDC");
55 cont->cd(2);
56 gPad->SetGrid();
57 h2->Draw("cont1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT1","brNDC");
58 cont->cd(3);
59 gPad->SetGrid();
60 h2->Draw("cont2"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT2","brNDC");
61 cont->cd(4);
62 gPad->SetGrid();
63 h2->Draw("cont3"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"CONT3","brNDC");
64 cont->Update();
65
66 //lego options
67 auto lego = new TCanvas("lego","lego options",150,150,800,600);
68 lego->Divide(2,2);
69 lego->SetFillColor(cancolor);
70 lego->cd(1);
71 h2->Draw("lego"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"LEGO","brNDC");
72 lego->cd(2);
73 h2->Draw("lego1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"LEGO1","brNDC");
74 lego->cd(3);
75 gPad->SetTheta(61); gPad->SetPhi(-82);
76 h2->Draw("surf1pol"); pl.DrawPaveLabel(xMin,yMin,xMax+0.05,yMax,"SURF1POL","brNDC");
77 lego->cd(4);
78 gPad->SetTheta(21); gPad->SetPhi(-90);
79 h2->Draw("surf1cyl"); pl.DrawPaveLabel(xMin,yMin,xMax+0.05,yMax,"SURF1CYL","brNDC");
80 lego->Update();
81
82 //surface options
83 auto surf = new TCanvas("surfopt","surface options",200,200,800,600);
84 surf->Divide(2,2);
85 surf->SetFillColor(cancolor);
86 surf->cd(1);
87 h2->Draw("surf1"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF1","brNDC");
88 surf->cd(2);
89 h2->Draw("surf2z"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF2Z","brNDC");
90 surf->cd(3);
91 h2->Draw("surf3"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF3","brNDC");
92 surf->cd(4);
93 h2->Draw("surf4"); pl.DrawPaveLabel(xMin,yMin,xMax,yMax,"SURF4","brNDC");
94 surf->Update();
95}
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
double Double_t
Definition RtypesCore.h:59
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
#define gPad
The Canvas class.
Definition TCanvas.h:23
virtual void SetParameters(const Double_t *params)
Definition TF1.h:670
A 2-Dim function with parameters.
Definition TF2.h:29
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
A Pave (see TPave) with a text centered in the Pave.
Definition TPaveLabel.h:20
virtual TPaveLabel * 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.
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:1636
void SetFrameFillColor(Color_t color=1)
Definition TStyle.h:369
void SetCanvasColor(Color_t color=19)
Definition TStyle.h:341
void lego()
Definition lego.C:31