From 083702b3b1abc24a3d822c6e6dc96ad7a9f2ab06 Mon Sep 17 00:00:00 2001 From: flatberg Date: Sat, 15 Dec 2007 14:50:33 +0000 Subject: [PATCH] Fixed bug in color updating --- fluents/plots.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/fluents/plots.py b/fluents/plots.py index fd7416d..108d9d5 100644 --- a/fluents/plots.py +++ b/fluents/plots.py @@ -396,11 +396,13 @@ class ScatterPlot(Plot): # init draw self.init_draw() - # signals to enable correct use of blit - self.connect('zoom-changed', self.onzoom) - self.connect('pan-changed', self.onpan) - self.need_redraw = False - self.canvas.mpl_connect('resize_event', self.onresize) + # fixme: taking out blit support for now + # + # # signals to enable correct use of blit + # self.connect('zoom-changed', self.onzoom) + # self.connect('pan-changed', self.onpan) + # self.need_redraw = False + # self.canvas.mpl_connect('resize_event', self.onresize) def add_axes_spin_buttons(self, max=None, absi=0, ordi=1): self._absi = absi @@ -439,10 +441,7 @@ class ScatterPlot(Plot): self.yaxis_data = xy[:,1] self.sc._offsets = xy self.selection_collection._offsets = xy - self.canvas.draw_idle() - pad = abs(self.xaxis_data.min()-self.xaxis_data.max())*0.05 - new_lims = (self.xaxis_data.min() - pad, self.xaxis_data.max() + pad) - self.axes.set_xlim(new_lims, emit=True) + self._reset_limits(0) self.canvas.draw_idle() def set_ordinate(self, sb): @@ -452,9 +451,7 @@ class ScatterPlot(Plot): self.yaxis_data = xy[:,1] self.sc._offsets = xy self.selection_collection._offsets = xy - pad = abs(self.yaxis_data.min()-self.yaxis_data.max())*0.05 - new_lims = (self.yaxis_data.min() - pad, self.yaxis_data.max() + pad) - self.axes.set_ylim(new_lims, emit=True) + self._reset_limits(1) self.canvas.draw_idle() def onzoom(self, widget, mode): @@ -500,10 +497,11 @@ class ScatterPlot(Plot): self._background = self.canvas.copy_from_bbox(self.axes.bbox) def _reset_limits(self, axis): + """ Resets vievlimits to datarange.""" if axis == 0: cax = self.xaxis_data set_lim = self.axes.set_xlim - elif axis == 1: + elif axis == 1 or axis == -1: set_lim = self.axes.set_ylim cax = self.yaxis_data else: @@ -584,7 +582,8 @@ class ScatterPlot(Plot): lut_l = 1.*self.sc.cmap._lut.shape[0] map_vec_range = map_vec.ptp() delta_lut = map_vec_range/lut_l - map_vec[vec_max + delta] = vec_max + delta_lut/2. + # just add a small value to distinct nans/infs etc. + map_vec[map_vec==(vec_max + delta)] = vec_max + delta_lut/2. self.sc.cmap._lut[-1,:] = [.5, .5, .5, 1] else: print "No lut present"