1 def _show_histogram_1d(h, yscale, xscale, curves):
3 import matplotlib.pyplot
as plt
4 import matplotlib.mlab
as mlab
6 ax= fig.add_subplot(111)
8 countsgrid= h.get_counts()
9 bins=[countsgrid.get_bounding_box(i).get_corner(0)[0]
for i
in countsgrid.get_all_indexes()]
10 counts= h.get_counts().get_all_voxels()
11 gbb=h.get_bounding_box()
13 ax.bar(bins, counts, align=
'edge', width=bins[1]-bins[0])
15 ax.plot(bins, counts,
"bx-", linewidth=2)
16 ax.set_xlim(gbb.get_corner(0)[0],
21 ax.set_autoscaley_on(
False)
23 ax.plot(bins, [c(x)
for x
in bins],
"go-", linewidth=1)
26 def _show_histogram_2d(h, yscale, xscale):
28 import matplotlib.cm
as cm
29 import matplotlib.mlab
as mlab
30 import matplotlib.pyplot
as plt
32 steps=cg.get_unit_cell()
33 x = np.arange(cg.get_bounding_box().get_corner(0)[0]+.5*steps[0],
34 cg.get_bounding_box().get_corner(1)[0]-.5*steps[0])
35 y = np.arange(cg.get_bounding_box().get_corner(0)[1]+.5*steps[1],
36 cg.get_bounding_box().get_corner(1)[1]-.5*steps[1])
37 X, Y = np.meshgrid(x, y)
38 Z,junk= np.meshgrid(x,y)
39 for i,xi
in enumerate(x):
40 for j, yj
in enumerate(y):
42 im = plt.pcolor(X,Y, Z, cmap=cm.jet)
48 for i
in range(0, bb.get_dimension()):
49 l= bb.get_corner(1)[i]-bb.get_corner(0)[i]
54 def _show_histogram_3d(h, vmin, vmax):
57 if not vmin
or not vmax:
58 minmax= h.get_minimum_and_maximum();
66 print >> sys.stderr,
"No pivy found"
69 for idx
in cg.get_all_indexes():
74 coords= cg.get_center(idx)
75 r= .25*_get_min_dim(cg.get_bounding_box(idx))
78 scaled= (v-vmin)/(vmax-vmin)
87 curves=[], vmin=
None, vmax=
None):
88 if h.get_dimension()==1:
89 _show_histogram_1d(h, yscale, xscale, curves)
90 elif h.get_dimension()==2:
91 _show_histogram_2d(h, yscale, xscale)
92 elif h.get_dimension()==3:
93 _show_histogram_3d(h, vmin, vmax)
95 raise ValueError(
"Dimension "+str(h.get_dimension())+
"not supported")