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]
10 for i
in countsgrid.get_all_indexes()]
11 counts = h.get_counts().get_all_voxels()
12 gbb = h.get_bounding_box()
13 if yscale ==
'linear':
14 ax.bar(bins, counts, align=
'edge', width=bins[1] - bins[0])
16 ax.plot(bins, counts,
"bx-", linewidth=2)
17 ax.set_xlim(gbb.get_corner(0)[0],
22 ax.set_autoscaley_on(
False)
24 ax.plot(bins, [c(x)
for x
in bins],
"go-", linewidth=1)
28 def _show_histogram_2d(h, yscale, xscale):
30 import matplotlib.cm
as cm
31 import matplotlib.mlab
as mlab
32 import matplotlib.pyplot
as plt
34 steps = cg.get_unit_cell()
35 x = np.arange(cg.get_bounding_box().get_corner(0)[0] + .5 * steps[0],
36 cg.get_bounding_box().get_corner(1)[0] - .5 * steps[0])
37 y = np.arange(cg.get_bounding_box().get_corner(0)[1] + .5 * steps[1],
38 cg.get_bounding_box().get_corner(1)[1] - .5 * steps[1])
39 X, Y = np.meshgrid(x, y)
40 Z, junk = np.meshgrid(x, y)
41 for i, xi
in enumerate(x):
42 for j, yj
in enumerate(y):
44 im = plt.pcolor(X, Y, Z, cmap=cm.jet)
51 for i
in range(0, bb.get_dimension()):
52 l = bb.get_corner(1)[i] - bb.get_corner(0)[i]
58 def _show_histogram_3d(h, vmin, vmax):
61 if not vmin
or not vmax:
62 minmax = h.get_minimum_and_maximum()
70 print >> sys.stderr,
"No pivy found"
73 for idx
in cg.get_all_indexes():
78 coords = cg.get_center(idx)
79 r = .25 * _get_min_dim(cg.get_bounding_box(idx))
82 scaled = (v - vmin) / (vmax - vmin)
92 curves=[], vmin=
None, vmax=
None):
93 if h.get_dimension() == 1:
94 _show_histogram_1d(h, yscale, xscale, curves)
95 elif h.get_dimension() == 2:
96 _show_histogram_2d(h, yscale, xscale)
97 elif h.get_dimension() == 3:
98 _show_histogram_3d(h, vmin, vmax)
101 "Dimension " + str(h.get_dimension()) +
"not supported")
Color get_hot_color(double f)
Return the color for f from the hot color map.
void show_histogram(HistogramD h, std::string xscale="linear", std::string yscale="linear", Functions curves=Functions())
Output IMP model data in various file formats.