Projects/laydi
Projects
/
laydi
Archived
7
0
Fork 0

Fixed bug in color updating

This commit is contained in:
Arnar Flatberg 2007-12-15 14:50:33 +00:00
parent e80440472d
commit 083702b3b1
1 changed files with 13 additions and 14 deletions

View File

@ -396,11 +396,13 @@ class ScatterPlot(Plot):
# init draw # init draw
self.init_draw() self.init_draw()
# signals to enable correct use of blit # fixme: taking out blit support for now
self.connect('zoom-changed', self.onzoom) #
self.connect('pan-changed', self.onpan) # # signals to enable correct use of blit
self.need_redraw = False # self.connect('zoom-changed', self.onzoom)
self.canvas.mpl_connect('resize_event', self.onresize) # 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): def add_axes_spin_buttons(self, max=None, absi=0, ordi=1):
self._absi = absi self._absi = absi
@ -439,10 +441,7 @@ class ScatterPlot(Plot):
self.yaxis_data = xy[:,1] self.yaxis_data = xy[:,1]
self.sc._offsets = xy self.sc._offsets = xy
self.selection_collection._offsets = xy self.selection_collection._offsets = xy
self.canvas.draw_idle() self._reset_limits(0)
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.canvas.draw_idle() self.canvas.draw_idle()
def set_ordinate(self, sb): def set_ordinate(self, sb):
@ -452,9 +451,7 @@ class ScatterPlot(Plot):
self.yaxis_data = xy[:,1] self.yaxis_data = xy[:,1]
self.sc._offsets = xy self.sc._offsets = xy
self.selection_collection._offsets = xy self.selection_collection._offsets = xy
pad = abs(self.yaxis_data.min()-self.yaxis_data.max())*0.05 self._reset_limits(1)
new_lims = (self.yaxis_data.min() - pad, self.yaxis_data.max() + pad)
self.axes.set_ylim(new_lims, emit=True)
self.canvas.draw_idle() self.canvas.draw_idle()
def onzoom(self, widget, mode): def onzoom(self, widget, mode):
@ -500,10 +497,11 @@ class ScatterPlot(Plot):
self._background = self.canvas.copy_from_bbox(self.axes.bbox) self._background = self.canvas.copy_from_bbox(self.axes.bbox)
def _reset_limits(self, axis): def _reset_limits(self, axis):
""" Resets vievlimits to datarange."""
if axis == 0: if axis == 0:
cax = self.xaxis_data cax = self.xaxis_data
set_lim = self.axes.set_xlim set_lim = self.axes.set_xlim
elif axis == 1: elif axis == 1 or axis == -1:
set_lim = self.axes.set_ylim set_lim = self.axes.set_ylim
cax = self.yaxis_data cax = self.yaxis_data
else: else:
@ -584,7 +582,8 @@ class ScatterPlot(Plot):
lut_l = 1.*self.sc.cmap._lut.shape[0] lut_l = 1.*self.sc.cmap._lut.shape[0]
map_vec_range = map_vec.ptp() map_vec_range = map_vec.ptp()
delta_lut = map_vec_range/lut_l 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] self.sc.cmap._lut[-1,:] = [.5, .5, .5, 1]
else: else:
print "No lut present" print "No lut present"