ROOT
CLING_PROFILE
Reference Guide
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
27
void
gr103_zones() {
28
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"multipads"
,900,700);
29
gStyle
->SetOptStat(0);
30
c1
->Divide(2,2,0,0);
31
TH2F
*
h1
=
new
TH2F
(
"h1"
,
"test1"
,10,0,1,20,0,20);
32
TH2F
*h2 =
new
TH2F
(
"h2"
,
"test2"
,10,0,1,20,0,100);
33
TH2F
*h3 =
new
TH2F
(
"h3"
,
"test3"
,10,0,1,20,-1,1);
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);
43
h2->
GetYaxis
()->
SetLabelOffset
(0.01);
44
h2->
Draw
();
45
46
c1
->cd(3);
47
h3->
Draw
();
48
49
c1
->cd(4);
50
gPad
->SetTicky(2);
51
h4->
Draw
();
52
}
gStyle
externTStyle * gStyle
Definition
TStyle.h:442
gPad
#define gPad
Definition
TVirtualPad.h:322
TAttAxis::SetLabelOffset
virtual void SetLabelOffset(Float_t offset=0.005)
Set distance between the axis and the labels.
Definition
TAttAxis.cxx:172
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH1::GetYaxis
TAxis * GetYaxis()
Definition
TH1.h:572
TH1::Draw
void Draw(Option_t *option="") override
Default Draw method for all objects.
TH2F
2-D histogram with a float per channel (see TH1 documentation)
Definition
TH2.h:345
c1
return c1
Definition
legend1.C:41
h1
TH1F * h1
Definition
legend1.C:5
gr103_zones
Definition
gr103_zones.py:1
tutorials
visualisation
graphs
gr103_zones.C
ROOTCLING_PROFILE - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1