Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Fixed histogram plot to accept selections of one, and made ad-hoc choice of proportional color to patches

This commit is contained in:
Arnar Flatberg 2007-08-02 14:37:19 +00:00
parent 7a0e2481eb
commit 0758ab8bfb
1 changed files with 18 additions and 4 deletions

View File

@ -581,7 +581,11 @@ class HistogramPlot(Plot):
self.axes.grid(False) self.axes.grid(False)
bins = min(self._data.size, kw['bins']) bins = min(self._data.size, kw['bins'])
count, lims, self.patches = self.axes.hist(self._data, bins=bins) count, lims, self.patches = self.axes.hist(self._data, bins=bins)
print "Number of pathes: %s" %len(self.patches)
print "Counts: "
print count
print "Lims:"
print lims
# Add identifiers to the individual patches # Add identifiers to the individual patches
if self.current_dim != None: if self.current_dim != None:
for i, patch in enumerate(self.patches): for i, patch in enumerate(self.patches):
@ -592,9 +596,12 @@ class HistogramPlot(Plot):
bool_ind = scipy.bitwise_and(self._data>=lims[i], bool_ind = scipy.bitwise_and(self._data>=lims[i],
self._data<=end_lim) self._data<=end_lim)
patch.index = scipy.where(bool_ind)[0] patch.index = scipy.where(bool_ind)[0]
print "Patch index: "
print (i, patch.index, count[i])
if self.current_dim==None: if self.current_dim==None:
# Disable selection modes # Disable selection modes
logger.log('notice', 'Disabled selections in Histogram Plot')
self._toolbar.freeze_button.set_sensitive(False) self._toolbar.freeze_button.set_sensitive(False)
self._toolbar.set_mode_sensitive('select', False) self._toolbar.set_mode_sensitive('select', False)
self._toolbar.set_mode_sensitive('lassoselect', False) self._toolbar.set_mode_sensitive('lassoselect', False)
@ -611,7 +618,7 @@ class HistogramPlot(Plot):
for patch in self.patches: for patch in self.patches:
xmin = patch.xy[0] xmin = patch.xy[0]
xmax = xmin + patch.get_width() xmax = xmin + patch.get_width()
ymin, ymax = 0, patch.get_height() ymin, ymax = -0.001, patch.get_height()
if xmax>x1 and xmin<x2 and (ymax> y2 or ymax>y1): if xmax>x1 and xmin<x2 and (ymax> y2 or ymax>y1):
self.active_patches.append(patch) self.active_patches.append(patch)
if not self.active_patches: return if not self.active_patches: return
@ -642,8 +649,15 @@ class HistogramPlot(Plot):
for patch in self.patches: for patch in self.patches:
patch.set_facecolor('b') patch.set_facecolor('b')
for patch in self.patches: for patch in self.patches:
if scipy.intersect1d(patch.index, index).size>1: bin_selected = scipy.intersect1d(patch.index, index).size
patch.set_facecolor('r') if bin_selected>0:
bin_total = len(patch.index)
# fixme: engineering color
prop = -scipy.log(1.0*bin_selected/bin_total)
b = min(prop, 1)
r = max(.5, 1-b)
g = 0
patch.set_facecolor((r,g,b,1))
self.canvas.draw() self.canvas.draw()