qt - Drawing a matplotlib figure without drawing the lines -
i've embedded matplotlib figure in qt (using pyside bindings), , using draw function redraw figure:
self.canvas.figure.draw()
i'm panning , zooming figure, , have been using draw method show new perspectives zooming in (using set_xlim , set_ylim) , panning (drag_pan , start_pan). there way redraw figure, ignore redrawing newly plotted points? when pans, i'm making new plots using blit, want make sure isn't being redone during draw method , running efficiently possible
edit/update: below code snippet of how i'm panning (inspired code navigationaltoolbar):
def on_drag(self, event): x, y = event.x, event.y if event.button == 1 , not event.dblclick , self.zoom.zoom_level != 0: self._button_pressed = 1 self.cursor.dragging_enabled = true self._xypress = [] i, in enumerate(self.canvas.figure.get_axes()): if (x not none , y not none): # , a.in_axes(event)): a.start_pan(x, y, event.button) self._xypress.append((a)) self._iddrag = self.canvas.mpl_connect('motion_notify_event', self.drag_pan) def drag_pan(self,event): self.canvas.update() self.canvas.flush_events() x, y = self.calculate_center_coords() self.pan_center_x = x self.pan_center_y = y in self._xypress: a.drag_pan(self._button_pressed, event.key, event.x, event.y) x_diff = self.pan_center_x / event.xdata y_diff = self.pan_center_y / event.ydata if self.zoom.zoom_level == 1: if ((x_diff > 1.04590 , x_diff < 1.05090) or (x_diff < 0.95715 , x_diff > 0.95215) or (y_diff > 1.03550 , y_diff < 1.04450) or (y_diff < 0.97215 , y_diff > 0.96115)): x, y = self.calculate_center_coords() self.pan_center_x = x self.pan_center_y = y #method replots points using blit self.panning() #redraws canvas, bottleneck self.canvas.draw()
Comments
Post a Comment