def calculate_histogram(self):
slice = self.pick_slice.value()
ax = self.figure.add_subplot(111)
ax.hold(False)
plt.cla()
n_channels = len(self.zcoord)
hues = np.arange(0, 1, 1 / n_channels)
self.colors = [colorsys.hsv_to_rgb(_, 1, 1) for _ in hues]
self.bins = np.arange(np.amin(np.hstack(self.zcoord)),np.amax(np.hstack(self.zcoord)),slice)
self.patches = []
ax.hold(True)
for i in range(len(self.zcoord)):
n, bins, patches = plt.hist(self.zcoord[i], self.bins, normed=1, facecolor=self.colors[i], alpha=0.5)
self.patches.append(patches)
plt.xlabel('Z-Coordinate [nm]')
plt.ylabel('Counts')
plt.title(r'$\mathrm{Histogram\ of\ Z:}$')
# refresh canvas
self.canvas.draw()
self.sl.setMaximum(len(self.bins)-2)
#self.sl.setValue(np.ceil((len(self.bins)-2)/2))
评论列表
文章目录