From 0758ab8bfbf0b0c001b82d84333d9145d606e025 Mon Sep 17 00:00:00 2001 From: flatberg Date: Thu, 2 Aug 2007 14:37:19 +0000 Subject: [PATCH] Fixed histogram plot to accept selections of one, and made ad-hoc choice of proportional color to patches --- fluents/plots.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fluents/plots.py b/fluents/plots.py index 5c55e86..e7beedc 100644 --- a/fluents/plots.py +++ b/fluents/plots.py @@ -581,7 +581,11 @@ class HistogramPlot(Plot): self.axes.grid(False) bins = min(self._data.size, kw['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 if self.current_dim != None: for i, patch in enumerate(self.patches): @@ -592,9 +596,12 @@ class HistogramPlot(Plot): bool_ind = scipy.bitwise_and(self._data>=lims[i], self._data<=end_lim) patch.index = scipy.where(bool_ind)[0] + print "Patch index: " + print (i, patch.index, count[i]) if self.current_dim==None: # Disable selection modes + logger.log('notice', 'Disabled selections in Histogram Plot') self._toolbar.freeze_button.set_sensitive(False) self._toolbar.set_mode_sensitive('select', False) self._toolbar.set_mode_sensitive('lassoselect', False) @@ -611,7 +618,7 @@ class HistogramPlot(Plot): for patch in self.patches: xmin = patch.xy[0] xmax = xmin + patch.get_width() - ymin, ymax = 0, patch.get_height() + ymin, ymax = -0.001, patch.get_height() if xmax>x1 and xmin y2 or ymax>y1): self.active_patches.append(patch) if not self.active_patches: return @@ -642,8 +649,15 @@ class HistogramPlot(Plot): for patch in self.patches: patch.set_facecolor('b') for patch in self.patches: - if scipy.intersect1d(patch.index, index).size>1: - patch.set_facecolor('r') + bin_selected = scipy.intersect1d(patch.index, index).size + 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()