ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
gr103_zones.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_graphs
3
## \notebook
4
## 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. Original tutorial by Rene Brun.
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
## \macro_image
23
## \macro_code
24
## \author Alberto Ferro
25
26
import
ROOT
27
28
c1 = ROOT.TCanvas(
"c1"
,
"multipads"
,900,700)
29
ROOT.gStyle.SetOptStat(0)
30
31
c1.Divide(2,2,0,0)
32
h1 = ROOT.TH2F(
"h1"
,
"test1"
,10,0,1,20,0,20)
33
h2 = ROOT.TH2F(
"h2"
,
"test2"
,10,0,1,20,0,100)
34
h3 = ROOT.TH2F(
"h3"
,
"test3"
,10,0,1,20,-1,1)
35
h4 = ROOT.TH2F(
"h4"
,
"test4"
,10,0,1,20,0,1000)
36
37
c1.cd(1)
38
ROOT.gPad.SetTickx(2)
39
h1.Draw()
40
c1.cd(2)
41
ROOT.gPad.SetTickx(2)
42
ROOT.gPad.SetTicky(2)
43
h2.GetYaxis().SetLabelOffset(0.01)
44
h2.Draw()
45
c1.cd(3)
46
h3.Draw()
47
c1.cd(4)
48
ROOT.gPad.SetTicky(2)
49
h4.Draw()
50
tutorials
visualisation
graphs
gr103_zones.py
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1