22 from ROOT
import TCanvas, TF1, gSystem, gPad, TLegend, TPaveLabel, kBlack
25 gSystem.Load(
"libMathMore")
27 DistCanvas =
TCanvas(
"DistCanvas",
"Bessel functions example", 10, 10, 800, 600)
28 DistCanvas.SetFillColor(17)
29 DistCanvas.Divide(2, 2)
32 gPad.SetFrameFillColor(19)
33 leg =
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)
50 xaxis = JBessel[0].GetXaxis()
52 xaxis.SetTitleSize(0.06)
53 xaxis.SetTitleOffset(.7)
56 p1 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel J functions",
"NDC")
59 p1.SetTextColor(kBlack)
62 leg.AddEntry(JBessel[0].DrawCopy(),
" J_0(x)",
"l")
63 leg.AddEntry(JBessel[1].DrawCopy(
"same"),
" J_1(x)",
"l")
64 leg.AddEntry(JBessel[2].DrawCopy(
"same"),
" J_2(x)",
"l")
65 leg.AddEntry(JBessel[3].DrawCopy(
"same"),
" J_3(x)",
"l")
66 leg.AddEntry(JBessel[4].DrawCopy(
"same"),
" J_4(x)",
"l")
74 gPad.SetFrameFillColor(19)
75 leg2 =
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)
87 kxaxis = KBessel[0].GetXaxis()
89 kxaxis.SetTitleSize(0.06)
90 kxaxis.SetTitleOffset(.7)
93 p2 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel K functions",
"NDC")
96 p2.SetTextColor(kBlack)
99 leg2.AddEntry(KBessel[0].DrawCopy(),
" K_0(x)",
"l")
100 leg2.AddEntry(KBessel[1].DrawCopy(
"same"),
" K_1(x)",
"l")
101 leg2.AddEntry(KBessel[2].DrawCopy(
"same"),
" K_2(x)",
"l")
102 leg2.AddEntry(KBessel[3].DrawCopy(
"same"),
" K_3(x)",
"l")
103 leg2.AddEntry(KBessel[4].DrawCopy(
"same"),
" K_4(x)",
"l")
110 gPad.SetFrameFillColor(19)
111 leg3 =
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)
124 iaxis = iBessel[0].GetXaxis()
126 iaxis.SetTitleSize(0.06)
127 iaxis.SetTitleOffset(.7)
130 p3 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel I functions",
"NDC")
133 p3.SetTextColor(kBlack)
136 leg3.AddEntry(iBessel[0].DrawCopy(),
" I_0",
"l")
137 leg3.AddEntry(iBessel[1].DrawCopy(
"same"),
" I_1(x)",
"l")
138 leg3.AddEntry(iBessel[2].DrawCopy(
"same"),
" I_2(x)",
"l")
139 leg3.AddEntry(iBessel[3].DrawCopy(
"same"),
" I_3(x)",
"l")
140 leg3.AddEntry(iBessel[4].DrawCopy(
"same"),
" I_4(x)",
"l")
147 gPad.SetFrameFillColor(19)
148 leg4 =
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)
160 jaxis = jBessel[0].GetXaxis()
162 jaxis.SetTitleSize(0.06)
163 jaxis.SetTitleOffset(.7)
166 p4 =
TPaveLabel(.0, .90, .0 + .50, .90 + .10,
"Bessel j functions",
"NDC")
169 p4.SetTextColor(kBlack)
172 leg4.AddEntry(jBessel[0].DrawCopy(),
" j_0(x)",
"l")
173 leg4.AddEntry(jBessel[1].DrawCopy(
"same"),
" j_1(x)",
"l")
174 leg4.AddEntry(jBessel[2].DrawCopy(
"same"),
" j_2(x)",
"l")
175 leg4.AddEntry(jBessel[3].DrawCopy(
"same"),
" j_3(x)",
"l")
176 leg4.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.