From 4ce6963428c3868c1670660f0c82d90c0dd2f486 Mon Sep 17 00:00:00 2001 From: einarr Date: Sat, 22 Aug 2009 17:41:06 +0000 Subject: [PATCH] Fixing selections and drawing in newer versions of matplotlib. --- laydi/plots.py | 7 ++++--- laydi/view.py | 18 +++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/laydi/plots.py b/laydi/plots.py index 8a264e8..4150e8c 100644 --- a/laydi/plots.py +++ b/laydi/plots.py @@ -341,6 +341,7 @@ class ScatterMarkerPlot(Plot): self.selection_listener(self.current_dim, ids) def set_current_selection(self, selection): + print "set_current_selection" #remove old selection if self._selection_line: self.axes.lines.remove(self._selection_line) @@ -477,7 +478,7 @@ class ScatterPlot(Plot): def init_draw(self): lw = scipy.zeros(self.xaxis_data.shape) - self.sc = self.axes.scatter(self.xaxis_data, self.yaxis_data, + self.sc = self.axes.scatter(self.xaxis_data, self.yaxis_data, edgecolor='r', s=self.s, c=self.c, linewidth=lw, zorder=3, **self.kw) self._mappable = self.sc @@ -486,7 +487,7 @@ class ScatterPlot(Plot): alpha=0, c='w',s=self.s, edgecolor='r', - linewidth=0, + linewidth=4, zorder=4) self.axes.axhline(0, color='k', lw=1., zorder=1) self.axes.axvline(0, color='k', lw=1., zorder=1) @@ -618,7 +619,7 @@ class ScatterPlot(Plot): index = self.get_index_from_selection(self.dataset_1, selection) if len(index) > 0: linewidth[index] = 1.5 - self.selection_collection.set_linewidth(linewidth) + self.sc.set_linewidth(linewidth) if self._use_blit and len(index)>0 : if self._background is None: diff --git a/laydi/view.py b/laydi/view.py index 0f27663..48924ca 100644 --- a/laydi/view.py +++ b/laydi/view.py @@ -536,12 +536,12 @@ class PanPlotMode(PlotMode): self._xypress=[] for i, a in enumerate(self.canvas.figure.get_axes()): - if x is not None and y is not None and a.in_axes(x, y) \ + if x is not None and y is not None and a.in_axes(event) \ and a.get_navigate(): xmin, xmax = a.get_xlim() ymin, ymax = a.get_ylim() lim = xmin, xmax, ymin, ymax - self._xypress.append((x, y, a, i, lim,a.transData.deepcopy())) + self._xypress.append((x, y, a, i, lim,a.transData.frozen())) self.canvas.mpl_disconnect(self._motion_notify) cid = self.canvas.mpl_connect('motion_notify_event', @@ -580,8 +580,8 @@ class PanPlotMode(PlotMode): #safer to use the recorded button at the press than current button: #multiple button can get pressed during motion... if self._button_pressed==1: - lastx, lasty = trans.inverse_xy_tup( (lastx, lasty) ) - x, y = trans.inverse_xy_tup( (event.x, event.y) ) + lastx, lasty = trans.inverted().transform( (lastx, lasty) ) + x, y = trans.inverted().transform( (event.x, event.y) ) if a.get_xscale()=='log': dx=1-lastx/x else: @@ -608,15 +608,15 @@ class PanPlotMode(PlotMode): elif self._button_pressed==3: try: - dx=(lastx-event.x)/float(a.bbox.width()) - dy=(lasty-event.y)/float(a.bbox.height()) + dx=(lastx-event.x)/float(a.bbox.width) + dy=(lasty-event.y)/float(a.bbox.height) dx,dy=format_deltas(event,dx,dy) if a.get_aspect() != 'auto': dx = 0.5*(dx + dy) dy = dx alphax = pow(10.0,dx) alphay = pow(10.0,dy) - lastx, lasty = trans.inverse_xy_tup( (lastx, lasty) ) + lastx, lasty = trans.inverted().transform( (lastx, lasty) ) if a.get_xscale()=='log': xmin = lastx*(xmin/lastx)**alphax xmax = lastx*(xmax/lastx)**alphax @@ -934,8 +934,8 @@ class Selector: miny, maxy = self.eventpress.ydata, y if minx>maxx: minx, maxx = maxx, minx if miny>maxy: miny, maxy = maxy, miny - self.polygon.xy[0] = minx - self.polygon.xy[1] = miny + self.polygon.set_x(minx) + self.polygon.set_y(miny) self.polygon.set_width(maxx-minx) self.polygon.set_height(maxy-miny) xx = [minx, maxx, maxx, minx, minx]