Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
gr103_zones.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_graphs
3/// \notebook
4/// \preview Example of script showing how to divide a canvas
5/// into adjacent subpads + axis labels on the top and right side
6/// of the pads.
7///
8/// See the [Divide documentation](https://root.cern/doc/master/classTPad.html#a2714ddd7ba72d5def84edc1fbaea8658)
9///
10/// Note that the last 2 arguments in
11/// `c1->Divide(2,2,0,0)`
12/// define 0 space between the pads. With this, the axis labels where the pads
13/// touch may be cut, as in this tutorial. To avoid this, either add some spacing
14/// between pads (instead of 0) or change the limits of the plot in the pad (histos
15/// in this tutorial). E.g. `h3` could be defined as
16/// `TH2F *h3 = new TH2F("h3","test3",10,0,1,22,-1.1,1.1);`
17/// but note that this can change the displayed axis labels (requiring SetNdivisions
18/// to readjust).
19///
20/// SetLabelOffset changes the (perpendicular) distance to the axis. The label
21/// position along the axis cannot be changed
22///
23/// \macro_image
24/// \macro_code
25/// \author Rene Brun
26
27void gr103_zones() {
28 TCanvas *c1 = new TCanvas("c1","multipads",900,700);
30 c1->Divide(2,2,0,0);
31 TH2F *h1 = new TH2F("h1","test1",10,0,1,20,0,20);
34 TH2F *h4 = new TH2F("h4","test4",10,0,1,20,0,1000);
35
36 c1->cd(1);
37 gPad->SetTickx(2);
38 h1->Draw();
39
40 c1->cd(2);
41 gPad->SetTickx(2);
42 gPad->SetTicky(2);
45
46 c1->cd(3);
48
49 c1->cd(4);
50 gPad->SetTicky(2);
51 h4->Draw();
52}
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define gPad
The Canvas class.
Definition TCanvas.h:23
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3037
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
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:1642
return c1
Definition legend1.C:41
TH1F * h1
Definition legend1.C:5