22from ROOT
import TCanvas, TF1, gSystem, gPad, TLegend, TPaveLabel, kBlack
25gSystem.Load(
"libMathMore")
27DistCanvas =
TCanvas(
"DistCanvas",
"Bessel functions example", 10, 10, 800, 600)
28DistCanvas.SetFillColor(17)
29DistCanvas.Divide(2, 2)
32gPad.SetFrameFillColor(19)
33leg =
TLegend(0.75, 0.7, 0.89, 0.89)
41 jbessel =
TF1(
"J_0",
"ROOT::Math::cyl_bessel_j([0],x)", 0, 10)
42 jbessel.SetParameters(nu, 0.0)
44 jbessel.SetLineStyle(1)
45 jbessel.SetLineWidth(3)
46 jbessel.SetLineColor(nu + 1)
47 JBessel.append(jbessel)
50xaxis = JBessel[0].GetXaxis()
52xaxis.SetTitleSize(0.06)
53xaxis.SetTitleOffset(.7)
56p1 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel J functions",
"NDC")
59p1.SetTextColor(kBlack)
62leg.AddEntry(JBessel[0].DrawCopy(),
" J_0(x)",
"l")
63leg.AddEntry(JBessel[1].DrawCopy(
"same"),
" J_1(x)",
"l")
64leg.AddEntry(JBessel[2].DrawCopy(
"same"),
" J_2(x)",
"l")
65leg.AddEntry(JBessel[3].DrawCopy(
"same"),
" J_3(x)",
"l")
66leg.AddEntry(JBessel[4].DrawCopy(
"same"),
" J_4(x)",
"l")
74gPad.SetFrameFillColor(19)
75leg2 =
TLegend(0.75, 0.7, 0.89, 0.89)
80 kbessel =
TF1(
"J_0",
"ROOT::Math::cyl_bessel_k([0],x)", 0, 10)
81 kbessel.SetParameters(nu, 0.0)
82 kbessel.SetTitle(
"Bessel K functions")
83 kbessel.SetLineStyle(1)
84 kbessel.SetLineWidth(3)
85 kbessel.SetLineColor(nu+1)
86 KBessel.append(kbessel)
87kxaxis = KBessel[0].GetXaxis()
89kxaxis.SetTitleSize(0.06)
90kxaxis.SetTitleOffset(.7)
93p2 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel K functions",
"NDC")
96p2.SetTextColor(kBlack)
99leg2.AddEntry(KBessel[0].DrawCopy(),
" K_0(x)",
"l")
100leg2.AddEntry(KBessel[1].DrawCopy(
"same"),
" K_1(x)",
"l")
101leg2.AddEntry(KBessel[2].DrawCopy(
"same"),
" K_2(x)",
"l")
102leg2.AddEntry(KBessel[3].DrawCopy(
"same"),
" K_3(x)",
"l")
103leg2.AddEntry(KBessel[4].DrawCopy(
"same"),
" K_4(x)",
"l")
110gPad.SetFrameFillColor(19)
111leg3 =
TLegend(0.75, 0.7, 0.89, 0.89)
116 ibessel =
TF1(
"J_0",
"ROOT::Math::cyl_bessel_i([0],x)", 0, 10)
117 ibessel.SetParameters(nu, 0.0)
118 ibessel.SetTitle(
"Bessel I functions")
119 ibessel.SetLineStyle(1)
120 ibessel.SetLineWidth(3)
121 ibessel.SetLineColor(nu + 1)
122 iBessel.append(ibessel)
124iaxis = iBessel[0].GetXaxis()
126iaxis.SetTitleSize(0.06)
127iaxis.SetTitleOffset(.7)
130p3 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel I functions",
"NDC")
133p3.SetTextColor(kBlack)
136leg3.AddEntry(iBessel[0].DrawCopy(),
" I_0",
"l")
137leg3.AddEntry(iBessel[1].DrawCopy(
"same"),
" I_1(x)",
"l")
138leg3.AddEntry(iBessel[2].DrawCopy(
"same"),
" I_2(x)",
"l")
139leg3.AddEntry(iBessel[3].DrawCopy(
"same"),
" I_3(x)",
"l")
140leg3.AddEntry(iBessel[4].DrawCopy(
"same"),
" I_4(x)",
"l")
147gPad.SetFrameFillColor(19)
148leg4 =
TLegend(0.75, 0.7, 0.89, 0.89)
153 jbessel =
TF1(
"J_0",
"ROOT::Math::sph_bessel([0],x)", 0, 10)
154 jbessel.SetParameters(nu, 0.0)
155 jbessel.SetTitle(
"Bessel j functions")
156 jbessel.SetLineStyle(1)
157 jbessel.SetLineWidth(3)
158 jbessel.SetLineColor(nu+1)
159 jBessel.append(jbessel)
160jaxis = jBessel[0].GetXaxis()
162jaxis.SetTitleSize(0.06)
163jaxis.SetTitleOffset(.7)
166p4 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel j functions",
"NDC")
169p4.SetTextColor(kBlack)
172leg4.AddEntry(jBessel[0].DrawCopy(),
" j_0(x)",
"l")
173leg4.AddEntry(jBessel[1].DrawCopy(
"same"),
" j_1(x)",
"l")
174leg4.AddEntry(jBessel[2].DrawCopy(
"same"),
" j_2(x)",
"l")
175leg4.AddEntry(jBessel[3].DrawCopy(
"same"),
" j_3(x)",
"l")
176leg4.AddEntry(jBessel[4].DrawCopy(
"same"),
" j_4(x)",
"l")
This class displays a legend box (TPaveText) containing several legend entries.
A Pave (see TPave) with a text centered in the Pave.