本文整理汇总了Python中matplotlib.backends.backend_wxagg.FigureCanvasWxAgg.mpl_disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasWxAgg.mpl_disconnect方法的具体用法?Python FigureCanvasWxAgg.mpl_disconnect怎么用?Python FigureCanvasWxAgg.mpl_disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_wxagg.FigureCanvasWxAgg
的用法示例。
在下文中一共展示了FigureCanvasWxAgg.mpl_disconnect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MplPanel
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
if not self.colorbar:
self.colorbar = self.figure.colorbar(cf, ax = self.axes)
else:
self.colorbar.update_normal(cf)
self.colorbar.draw_all()
#draw figure
self.figure.canvas.draw()
def updateAngularOrigin(self, om0, tt0):
self.omega0 = om0
self.ttheta0 = tt0
[dummy, self.Q0x, self.Q0z] = self.hxrd.Ang2Q(self.omega0,self.ttheta0,delta=[0.0, 0.0])
def updateReciprocalOrigin(self, Q0x, Q0z):
self.Q0x = Q0x
self.Q0z = Q0z
#low incidence high exit angles for panalytical
[self.omega0, chi, phi, self.ttheta0] = self.hxrd.Q2Ang((0.0, self.Q0x, self.Q0z), geometry = 'lo_hi')
def update_qxMinLimit(self, qlim):
#get previous axes limits
qmin, qmax = self.figure.gca().get_xlim()
#set new axes limits
self.figure.gca().set_xlim(qlim, qmax)
#redraw figure
self.canvas.draw()
def update_qxMaxLimit(self, qlim):
#get previous axes limits
qmin, qmax = self.figure.gca().get_xlim()
#set new axes limits
self.figure.gca().set_xlim(qmin, qlim)
#redraw figure
self.canvas.draw()
def update_qzMinLimit(self, qlim):
#get previous axes limits
qmin, qmax = self.figure.gca().get_ylim()
#set new axes limits
self.figure.gca().set_ylim(qlim, qmax)
#redraw figure
self.canvas.draw()
def update_qzMaxLimit(self, qlim):
#get previous axes limits
qmin, qmax = self.figure.gca().get_ylim()
#set new axes limits
self.figure.gca().set_ylim(qmin, qlim)
#redraw figure
self.canvas.draw()
def getLimits(self):
qxmin, qxmax = self.figure.gca().get_xlim()
qzmin, qzmax = self.figure.gca().get_ylim()
return qxmin, qxmax, qzmin, qzmax
def get_q(self):
[dummy, qx, qz] = self.hxrd.Ang2Q(self.omega,self.ttheta, delta=[0.0, 0.0])
#subtract centeral point from arrays by list comprehension
qx[:] = [q - self.Q0x for q in qx]
qz[:] = [q - self.Q0z for q in qz]
return qx, qz
def get_intensity(self):
return self.intensity
def set_cursor(self):
# set useblit = True on gtkagg for enhanced performance
self.cursor = Cursor(self.axes, useblit=True, color='black', linewidth=1 )
#connect event handler on left button mouse click
self.cidrelease = self.canvas.mpl_connect(
'button_release_event', self.onLeftClick)
def unset_cursor(self):
if self.cursor:
#unset cursor
self.cursor = None
#disconnect event handler on left button mouse click
self.canvas.mpl_disconnect(self.cidrelease)
def onLeftClick(self, event):
self.unset_cursor()
# transform angles to reciprocal points
[qx,qy,qz] = self.hxrd.Ang2Q(self.omega,self.ttheta,delta=[0.0, 0.0])
dlg = PeakFitDialog(self)
#set position text controls equal to position of the mouse click
dlg.SetPeak("Peak 1", event.xdata, event.ydata)
#pass xray data
dlg.SetData(qy, qz, self.intensity)
if dlg.ShowModal() == wx.ID_OK:
#get peak from dialog
peak = dlg.GetPeak()
self.GetParent().stgPanel.addPeak(peak)
示例2: ScatterPlotWidget
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
class ScatterPlotWidget(wx.Panel, ManageBusyCursorMixin):
def __init__(self, parent, scatt_id, scatt_mgr, transpose,
id=wx.ID_ANY):
# TODO should not be transpose and scatt_id but x, y
wx.Panel.__init__(self, parent, id)
# bacause of aui (if floatable it can not take cursor from parent)
ManageBusyCursorMixin.__init__(self, window=self)
self.parent = parent
self.full_extend = None
self.mode = None
self._createWidgets()
self._doLayout()
self.scatt_id = scatt_id
self.scatt_mgr = scatt_mgr
self.cidpress = None
self.cidrelease = None
self.rend_dt = {}
self.transpose = transpose
self.inverse = False
self.SetSize((200, 100))
self.Layout()
self.base_scale = 1.2
self.Bind(wx.EVT_CLOSE, lambda event: self.CleanUp())
self.plotClosed = Signal("ScatterPlotWidget.plotClosed")
self.cursorMove = Signal("ScatterPlotWidget.cursorMove")
self.contex_menu = ScatterPlotContextMenu(plot=self)
self.ciddscroll = None
self.canvas.mpl_connect('motion_notify_event', self.Motion)
self.canvas.mpl_connect('button_press_event', self.OnPress)
self.canvas.mpl_connect('button_release_event', self.OnRelease)
self.canvas.mpl_connect('draw_event', self.DrawCallback)
self.canvas.mpl_connect('figure_leave_event', self.OnCanvasLeave)
def DrawCallback(self, event):
self.polygon_drawer.DrawCallback(event)
self.axes.draw_artist(self.zoom_rect)
def _createWidgets(self):
# Create the mpl Figure and FigCanvas objects.
# 5x4 inches, 100 dots-per-inch
#
self.dpi = 100
self.fig = Figure((1.0, 1.0), dpi=self.dpi)
self.fig.autolayout = True
self.canvas = FigCanvas(self, -1, self.fig)
self.axes = self.fig.add_axes([0.0, 0.0, 1, 1])
pol = Polygon(list(zip([0], [0])), animated=True)
self.axes.add_patch(pol)
self.polygon_drawer = PolygonDrawer(self.axes, pol=pol, empty_pol=True)
self.zoom_wheel_coords = None
self.zoom_rect_coords = None
self.zoom_rect = Polygon(list(zip([0], [0])), facecolor='none')
self.zoom_rect.set_visible(False)
self.axes.add_patch(self.zoom_rect)
def ZoomToExtend(self):
if self.full_extend:
self.axes.axis(self.full_extend)
self.canvas.draw()
def SetMode(self, mode):
self._deactivateMode()
if mode == 'zoom':
self.ciddscroll = self.canvas.mpl_connect(
'scroll_event', self.ZoomWheel)
self.mode = 'zoom'
elif mode == 'zoom_extend':
self.mode = 'zoom_extend'
elif mode == 'pan':
self.mode = 'pan'
elif mode:
self.polygon_drawer.SetMode(mode)
def SetSelectionPolygonMode(self, activate):
self.polygon_drawer.SetSelectionPolygonMode(activate)
def _deactivateMode(self):
self.mode = None
self.polygon_drawer.SetMode(None)
if self.ciddscroll:
self.canvas.mpl_disconnect(self.ciddscroll)
#.........这里部分代码省略.........
示例3: plotTimeSeries
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
def OnPlotType(self, ptype):
# self.timeSeries.clear()
if ptype == "line":
ls = '-'
m='None'
elif ptype == "point":
ls='None'
m='o'
else:
ls = '-'
m='o'
format = ls+m
for line, i in zip(self.lines, range(len(self.lines))):
if not (i == self.curveindex):
plt.setp(line, linestyle = ls, marker = m)
self.canvas.draw()
def Clear(self):
lines = []
for key, ax in self.axislist.items():
ax.clear()
# self.stopEdit()
def stopEdit(self):
self.Clear()
self.selectedlist = None
self.editPoint =None
self.lman= None
self.canvas.mpl_disconnect(self.cid)
self.cid=None
self.xys = None
self.curveindex = -1
self.editCurve =None
# self.RefreshPlot()
if self.seriesPlotInfo and self.seriesPlotInfo.IsPlotted(self.editseriesID):
self.updatePlot()
self.editseriesID = -1
def updateValues(self):
# self.addEdit(self.editCursor, self.editSeries, self.editDataFilter)
#clear current edit points and curve
curraxis= self.axislist[self.editCurve.axisTitle]
for l in curraxis.lines:
if l.get_label() == self.editCurve.plotTitle:
curraxis.lines.remove(l)
self.editPoint.remove()
#redraw editpoints and curve
self.seriesPlotInfo.UpdateEditSeries()
self.editCurve= self.seriesPlotInfo.GetEditSeriesInfo()
self.drawEditPlot(self.editCurve)
Publisher.sendMessage(("refreshTable"), e=None)
# self.parent.parent.dataTable.Refresh()
self.canvas.draw()
def drawEditPlot(self, oneSeries):
示例4: diffaction_int
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
# unless the user confirms the selection in this case ;-)
self.doiexit = wx.MessageDialog(self, "Do you want to quit?\n", "Warning", wx.YES_NO)
igot = self.doiexit.ShowModal() # Shows it
self.doiexit.Destroy()
if igot == wx.ID_YES:
self.Destroy() # Closes out this simple application
def OnOpen(self, e):
# In this case, the dialog is created within the method because
# the directory name, etc, may be changed during the running of the
# application. In theory, you could create one earlier, store it in
# your frame object and change it when it was called to reflect
# current parameters / values
dlg = wx.FileDialog(
self,
"Choose a diffraction image",
self.dirname,
"",
"Image Files|*.tif;*.TIF;*.tiff;*.TIFF;*.jpg;*.JPG;*.png;*.PNG;*.bmp;*.BMP;*.dm3;*.DM3|All Files|*.*",
wx.OPEN,
)
if dlg.ShowModal() == wx.ID_OK:
self.filename = dlg.GetFilename()
self.dirname = dlg.GetDirectory()
self.openimage()
print self.dirname
dlg.Destroy()
def openimage(self):
self.toolbar.circles = []
self.toolbar.point3 = array([])
self.canvas.mpl_disconnect(self.toolbar.cid)
name, ext = os.path.splitext(self.filename)
print self.dirname, name, ext, os.path.join(self.dirname, self.filename)
if ext == ".dm3" or ext == ".DM3":
dm3f = dm3.DM3(os.path.join(self.dirname, self.filename))
imageData = dm3f.getInfo()
print imageData, dm3f.pxsize
self.pattern_open = dm3f.getImageData()
# self.pattern_open = array(self.pattern_open)
self.pattern_open.shape
# print self.pattern_open[[182],[1336]]
a = self.img_con.value
print imageData["mag"], imageData["hv"]
self.accv = int(float(imageData["hv"]) / 1000.0)
if imageData["mode"] == "DIFFRACTION":
self.camlen = int(float(imageData["mag"]) / 10.0)
print self.camlen, self.accv
if dm3f.pxsize[0]:
if dm3f.pxsize[1] == "1/nm":
self.pixel_size = dm3f.pxsize[0] * 10 ** 9
print ".dm3 set pixel_size:", self.pixel_size
elif dm3f.pxsize[1] == "1/A":
self.pixel_size = dm3f.pxsize[0] * 10 ** 10
print ".dm3 set pixel_size:", self.pixel_size
elif dm3f.pxsize[1] == "1/m":
self.pixel_size = dm3f.pxsize[0]
print ".dm3 set pixel_size:", self.pixel_size
else:
self.PixelSize()
示例5: Plotter2D
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
X = numpy.floor((x - self.Xmin)/dx)
Y = numpy.floor((y - self.Ymin)/dy)
i = self.data[Y, X]
self.annotation.SetLabel('x : %g (%g), y : %g (%g), data[x,y] : %g'%(X,x*self.Xunit_conversion_factor,Y,y*self.Yunit_conversion_factor,i))
except:
self.annotation.SetLabel('') # rarely useful except outside figure
else:
self.annotation.SetLabel('')
def export_data(self, event = None):
header = '# Data : %s\n# First row : %s\n# First column : %s\n' % (self.varname,self.Xlabel,self.Ylabel)
output_fname = self.get_output_filename()
x = numpy.concatenate(([0],self.Xaxis))
data = numpy.vstack((x,numpy.hstack((self.Yaxis[:,numpy.newaxis],self.data))))
if output_fname:
with open(output_fname, 'w') as f:
f.write(header)
numpy.savetxt(f, data, fmt='%12.4e', delimiter=" ")
f.close()
def get_output_filename(self):
path = ''
dlg = wx.FileDialog(self, "Save As", '', '', "All Files|*.*", wx.SAVE)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
dlg.Destroy()
return path
def slice(self, event):
if not event.IsChecked():
self.canvas.mpl_disconnect(self.slice_event_id)
self.slice_event_id = None
self.menu_event_id = self.canvas.mpl_connect('button_press_event', self.on_click)
self.canvas.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
for w in self.slice_widget:
w.remove()
self.slice_widget = []
self.cross_slice_fig = None
self.segment_slice_fig = None
self.segment_slice_color_index = 0
self.cross_slice_color_index = -1
self.v_cross_slice_plot = None
self.h_cross_slice_plot = None
self.segment_slice_legend = []
self.h_cross_slice_legend = []
self.v_cross_slice_legend = []
if self.cross_slice_dialog:
self.cross_slice_dialog.Close()
self.canvas.draw()
return
self.canvas.mpl_disconnect(self.menu_event_id)
self.menu_event_id = None
self.slice_event_id = self.canvas.mpl_connect('button_press_event', self.build_slice_widget)
self.canvas.SetCursor(wx.CROSS_CURSOR)
self.canvas.draw()
def build_slice_widget(self, event):
if not event.inaxes:
return
示例6: _MPLFigureEditor
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
sizer.Add(self.canvas,1,wx.EXPAND|wx.ALL,1)
#toolbar=NavigationToolbar2Wx(self.canvas)
#toolbar.Realize()
#sizer.Add(toolbar,0,wx.EXPAND|wx.ALL,1)
panel.SetSizer(sizer)
#self.canvas.mpl_connect('button_press_event',
# lambda ev:self.object.circ_click(ev,self))
#self.motion_cid=self.canvas.mpl_connect('motion_notify_event',
# lambda ev:self.object.circ_mouseover(ev,self))
self.canvas.mpl_connect('button_press_event',self.object.circle_click)
self.canvas.mpl_connect('motion_notify_event',
lambda ev:self.object.circle_mouseover(ev,self.tooltip))
self.tooltip=wx.ToolTip(tip='')
self.tooltip.SetDelay(2000)
self.canvas.SetToolTip(self.tooltip)
return panel
def _process_click(self,event):
if event.button==3:
self.ds.display_all()
elif event.button==1 and (7 <= event.ydata <= 8):
n=self.ds.nr_labels*event.xdata/(np.pi*2)+.5*np.pi/self.ds.nr_labels
self.ds.display_node(int(np.floor(n)))
def _process_circ_click(self,event,cvu):
# if the user right clicked, just display all
if event.button==3:
cvu.display_all()
return
elif event.button==2:
self.object.mpleditor=self
return
# the user left clicked, lets wait and see if he wants to pan
self.release_cid=self.canvas.mpl_connect('button_release_event',
lambda ignore:self._single_click(event,cvu))
# use the existing event coordinates; theres probably no difference
# but if there were the originals would be more reliable
#self.motion_cid=self.canvas.mpl_connect('motion_notify_event',
# self._pan_decide)
def _single_click(self,event,cvu):
self._clear_callbacks()
#this event has xdata and ydata in reverse polar coordinates (theta,r)
#do some algebra to figure out which ROI based on the angle
if event.button==1 and event.ydata>=7 and event.ydata<=8:
nod=cvu.nr_labels*event.xdata/(np.pi*2)+.5*np.pi/cvu.nr_labels
#the formula for the correct node, assuming perfect clicking,
#is floor(n*theta/2pi). however, matplotlib seems to not do great
#with this, the clicking is often too high, so i add this correction
cvu.display_node(int(np.floor(nod)))
def _possibly_show_tooltip(self,event,cvu):
self._clear_callbacks()
if event.ydata>=7 and event.ydata<=8:
nod=int(np.floor(cvu.nr_labels*event.xdata/(np.pi*2)
+.5*np.pi/cvu.nr_labels))
self.tooltip.Enable(True)
self.tooltip.SetTip(cvu.labnam[nod])
else:
self.tooltip.Enable(False)
#if and when panning is also done, this logic needs to become a bit
#more complex to respond only to novel mouse events and constantly
#clear old callbacks.
#self.waiting_for_tooltip=True
#self.motion_cid=self.canvas.mpl_connect('motion_notify_event',
# self._move_unset_tooltip)
#time.sleep(1)
def _move_unset_tooltip(self,ignore):
self.waiting_for_tooltip=False
def _clear_callbacks(self):
self.canvas.mpl_disconnect(self.release_cid)
#self.canvas.mpl_disconnect(self.motion_cid)
def _pan_decide(self,event):
ax=self.canvas.figure.get_axes()[0]
ax.set_navigate_mode('PAN')
ax.start_pan(event.x,event.y,1)
self._pan(event)
self._clear_callbacks()
self.release_cid=self.canvas.mpl_connect('button_release_event',
self._end_pan)
self.motion_cid=self.canvas.mpl_connect('motion_notify_event',
self._pan)
def _pan(self,event):
ax = self.canvas.figure.get_axes()[0]
ax.drag_pan(1,event.key,event.x,event.y)
self.canvas.draw()
def _end_pan(self,event):
ax = self.canvas.figure.get_axes()[0]
ax.end_pan()
self._clear_callbacks()
示例7: SubjectFrame
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
self.redraw_timer.Start(50)
wx.EVT_TIMER(panel, self.redraw_timer.GetId(), self.redraw)
###
#self.subject.tick(self.no_adjustment, millis=500) # Session update timer
###
# END: Timers
###
self.init_subject()
###
# Finally, draw the window and disable all inputs and start the subject.
self.needs_redraw = True
#self.disable_widgets()
###
#self.subject.start()
###
################################
# BEGIN: Mouse event handling. #
################################
def connect_mouse_listeners(self):
'Begin listening for mouse clicks, drags, and releases.'
self.mouse_listeners.append(self.canvas.mpl_connect('button_press_event', self.drag_start))
self.mouse_listeners.append(self.canvas.mpl_connect('button_release_event', self.drag_stop))
self.mouse_listeners.append(self.canvas.mpl_connect('motion_notify_event', self.dragged))
def disconnect_mouse_listeners(self):
'Stop paying attention to mouse activity (before and between rounds).'
for cid in self.mouse_listeners:
self.canvas.mpl_disconnect(cid)
def drag_stop(self, event):
'Turn off the drag listener.'
if event.button == 1:
if self.dragging:
self.dragging = False
def drag_start(self, event):
'Turn on the drag listener.'
if event.button == 1 and event.inaxes is self.top_axes:
self.dragging = True
def dragged(self, event):
'Listener for mouse dragging. Updates the subject value based on the y-axis coordinate.'
if event.button == 1 and event.inaxes is self.top_axes:
if self.dragging:
y = int(event.ydata + 0.5)
self.slider.SetValue(y)
self.slider_adjusted(y)
##############################
# END: Mouse event handling. #
##############################
###############################
# BEGIN: Plot related methods #
###############################
def redraw(self,evt):
'Update and redraw the plots.'
###
"""
if self.needs_redraw:
示例8: MainPanel
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
class MainPanel(wx.Dialog):
def __init__(self, parent, pathToPlugins=None):#, main_playlist, nb_playlist):
if(not pathToPlugins==None):
RESFILE = os.path.join(pathToPlugins,'x2') + os.sep + "layout_x2.xml"
wx.Dialog.__init__(self, parent, -1, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
self.parent = parent
self.nb_playlist = 0
self.main_playlist = self.parent.lc_playlist
#self.super_parent = super_parent
# XML Resources can be loaded from a file like this:
res = xrc.XmlResource(RESFILE)
# Now create a panel from the resource data
panel = res.LoadPanel(self, "m_pa_x2main")
#self.panel = panel
#background = 'tulips.jpg'
#img = wx.Image(background, wx.BITMAP_TYPE_ANY)
#self.buffer = wx.BitmapFromImage(img)
#dc = wx.BufferedDC(wx.ClientDC(panel), self.buffer)
#self.panel.Bind(wx.EVT_PAINT, self.OnPaint)
# control references --------------------
self.pa_x2main = xrc.XRCCTRL(self, 'm_pa_x2main')
self.pa_x2_graph = xrc.XRCCTRL(self, 'm_pa_x2_graph')
self.lc_x2_plist = xrc.XRCCTRL(self, 'm_lc_x2_plist')
self.cl_x2_features = xrc.XRCCTRL(self, 'm_cl_x2_features')
self.sl_x2_pointsize = xrc.XRCCTRL(self, 'm_sl_x2_pointsize')
self.lc_x2_plist.InsertColumn(0,"Artist")
self.lc_x2_plist.InsertColumn(1,"Song")
self.lc_x2_plist.SetColumnWidth(0, 100)
self.lc_x2_plist.SetColumnWidth(1, 100)
self.Bind(wx.EVT_BUTTON, self.OnAutoGenerateX2Playist, id=xrc.XRCID('m_bu_x2_plize'))
self.Bind(wx.EVT_BUTTON, self.OnCenterClick, id=xrc.XRCID('m_bu_x2_center'))
self.Bind(wx.EVT_SLIDER, self.OnPointSizeClick, id=xrc.XRCID('m_sl_x2_pointsize'))
self.Bind(wx.EVT_SPIN, self.OnZoomClick, id=xrc.XRCID('m_sb_x2_zoom'))
self.Bind(wx.EVT_SPIN, self.OnPanXClick, id=xrc.XRCID('m_sb_x2_panx'))
self.Bind(wx.EVT_SPIN, self.OnPanYClick, id=xrc.XRCID('m_sb_x2_pany'))
self.Bind(wx.EVT_CHECKBOX, self.OnXAxisClick, id=xrc.XRCID('m_cb_x2_xlog'))
self.Bind(wx.EVT_CHECKBOX, self.OnYAxisClick, id=xrc.XRCID('m_cb_x2_ylog'))
self.Bind(wx.EVT_CHECKLISTBOX, self.OnCheckListBox, self.cl_x2_features)
self.current_zoom = 0
self.current_panx = 0
self.current_pany = 0
#features array
#tag_array = GetTags()
self.cl_x2_features.Set(FEATURES_ARRAY)
#self.cl_x2_features.AppendItems(tag_array)
self.figure = Figure(None, None, (1,1,1), None, 1.0, True, None)#facecolor=0.75, edgecolor='white')
#(figsize=None, dpi=None, facecolor=None, edgecolor=None, linewidth=1.0, frameon=True, subplotpars=None)
self.MakeScatt([0,1,2,3])
self.build_graph()
self.build_collection()
self.canvas = FigureCanvas(self.pa_x2_graph, -1, self.figure)
self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel)
self.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown)
#self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
self.Bind(wx.EVT_RIGHT_UP, self.OnMouseRightUp)
self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.OnMouseRightDown)
#self.canvas.Bind(wx.EVT_MOTION, self.OnMouseMotion)
self.canvas.Bind(wx.EVT_RIGHT_UP, self.OnMouseRightUp)
# Note that event is a MplEvent
#self.canvas.mpl_connect('motion_notify_event', self.OnMouseMotion)
#self.canvas.Bind(wx.EVT_ENTER_WINDOW, self.ChangeCursor)
#lasso
self.mpl = self.canvas.mpl_connect('button_press_event', self.onpress)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.pa_x2main, 1, wx.EXPAND|wx.ALL, 5)
self.SetSizer(sizer)
self.SetAutoLayout(True)
self.Fit()
# -----------------------------------------
# -----------------------------------------
def OnPaint(self, evt):
dc = wx.BufferedPaintDC(self.panel, self.buffer)
def ChangeCursor(self, curtype):
self.canvas.SetCursor(wx.StockCursor(curtype))
def OnMouseRightDown(self, evt):
self.canvas.mpl_disconnect(self.mpl)
self.canvas.Bind(wx.EVT_MOTION, self.OnMouseMotion)
self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
self.ChangeCursor(wx.CURSOR_HAND)
self.Refresh()
self.oldx = evt.GetPosition()[0]
self.oldy = evt.GetPosition()[1]
#.........这里部分代码省略.........
示例9: radial
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
#if plot_sub:
# axi2.lines.pop(-2)
# axi2.figure.canvas.draw()
plot_sub = axi2.plot(self.drdf,self.background,'r')
axi2.figure.canvas.draw()
rdf_max = self.rdf.max()
self.rdf -= self.background
#self.background[nonzero(self.background > rdf_max)] = rdf_max
#plot_sub = axi2.plot(self.drdf,self.background,'m')
start = nonzero(self.rdf>0)[0][0]
print self.rdf[start:].min()
self.rdf -= self.rdf[start:].min()
self.rdf[0:start] = 0
self.rdfb += [self.rdf.copy()]
self.drdfb += [self.drdf.copy()]
axi2.plot(self.drdf,self.rdf,'k')
axi2.figure.canvas.draw()
self.bgfitp = array([])
print self.toolbar.fid
self.toolbar.fid = self.canvas.mpl_disconnect(self.toolbar.fid)
print self.toolbar.fid
def OnClearPro(self,e):
self.axes.cla()
self.plot(2)
self.axes.figure.canvas.draw()
def OnClearProSim(self,e):
self.prosim = 0
self.axes.cla()
self.plot(2)
self.axes.figure.canvas.draw()
def OnClearSim(self,e):
self.simulations.pop(-1)
if len(self.simulations) <= 0:
self.plot_sim = 0
self.axes.cla()
self.plot(2)
self.axes.figure.canvas.draw()
def OnUndo(self,e):
axi2 = self.canvas.figure.axes[0]
axi2.cla()
print len(self.rdfb), len(self.rdfb[-1]), len(self.drdfb[-1])
if len(self.rdfb) > 1:
示例10: MainFrame
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
self.min_graph, = self.axes_det2.plot(
arange(width),
self.beatingdata.reconstructed_off)
self.max_graph, = self.axes_det2.plot(
arange(width),
self.beatingdata.reconstructed_on)
self.detailcanvas.draw()
self.axes_det1.autoscale()
self.axes_det2.autoscale()
else:
# Riattivare il vecchio grafico!
self.axes_det1.cla()
self.axes_det2.cla()
self.line_det_h, = self.axes_det1.plot(
arange(self.beatingdata.image_width),
zeros_like(arange(self.beatingdata.image_width)),
animated=True)
self.axes_det1.set_ylim(self.beatingdata.data.min(), self.beatingdata.data.max())
self.line_det_v, = self.axes_det2.plot(
arange(self.beatingdata.image_height),
zeros_like(arange(self.beatingdata.image_height)),
animated=True)
self.axes_det2.set_ylim(self.beatingdata.data.min(), self.beatingdata.data.max())
self.detailcanvas.draw()
self.background_h = self.detailcanvas.copy_from_bbox(self.axes_det1.bbox)
self.background_v = self.detailcanvas.copy_from_bbox(self.axes_det2.bbox)
def OnCloseMe(self, event):
self.Close(True)
def on_mouseover(self, event):
if event.inaxes == self.axes:
x, y = int(floor(event.xdata)), int(floor(event.ydata))
self.x, self.y = x, y
def on_mouseclick(self, event):
if event.inaxes == self.axes:
if not self.crosshair_lock:
self.crosshair_lock = True
self.deactivate_mouseover()
x, y = int(floor(event.xdata)), int(floor(event.ydata))
self.x, self.y = x, y
else:
self.crosshair_lock = False
x, y = int(floor(event.xdata)), int(floor(event.ydata))
self.x, self.y = x, y
self.activate_mouseover()
def activate_mouseover(self):
self.cid = self.canvas.mpl_connect('motion_notify_event',
self.on_mouseover)
self.timer.Start(80)
def deactivate_mouseover(self):
self.canvas.mpl_disconnect(self.cid)
self.timer.Stop()
def enter_axes(self, event):
self.in_axes = True
if not self.crosshair_lock:
self.activate_mouseover()
def leave_axes(self, event):
self.in_axes = False
if not self.crosshair_lock:
self.deactivate_mouseover()
self.statusbar.SetStatusText(" ")
self.beating_image.set_array(self.drawingdata)
self.canvas.draw()
if not self.cb_ratiograph.IsChecked():
self.axes_det1.clear()
self.axes_det2.clear()
self.detailcanvas.draw()
def callback(self, event):
if self.in_axes and (self.x != self.prevx or self.y != self.prevy):
x, y = self.x, self.y
value = self.drawingdata[y, x]
msg = "Coordinate: {0}, {1} Valore: {2}".format(x, y, value)
self.statusbar.SetStatusText(msg)
highlight_data = copy(self.drawingdata)
highlight_data[:, x] = highlight_data[:, x] * (1.0 - self.alpha) + highlight_data.max() * self.alpha
highlight_data[y, :] = highlight_data[y, :] * (1.0 - self.alpha) + highlight_data.max() * self.alpha
highlight_data[y, x] = value
self.beating_image.set_array(highlight_data)
self.canvas.draw()
# Aggiorno i dettagli
if not self.cb_ratiograph.IsChecked():
self.detailcanvas.restore_region(self.background_h)
self.detailcanvas.restore_region(self.background_v)
self.line_det_h.set_ydata(self.drawingdata[y, :])
self.line_det_v.set_ydata(self.drawingdata[:, x])
self.axes_det1.draw_artist(self.line_det_h)
self.axes_det2.draw_artist(self.line_det_v)
self.detailcanvas.blit(self.axes_det1.bbox)
self.detailcanvas.blit(self.axes_det2.bbox)
self.prevx, self.prevy = x, y
def on_slider_alpha(self, event):
self.alpha = self.slider_alpha.GetValue() / 100.0
示例11: plotTimeSeries
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
for line, i in zip(self.lines, range(len(self.lines))):
if not (i == self.curveindex):
plt.setp(line, linestyle=ls, marker=m)
if self.isShowLegendEnabled :
self.onShowLegend(self.isShowLegendEnabled)
plt.gcf().autofmt_xdate()
self.canvas.draw()
#clear plot
def clear(self):
lines = []
for key, ax in self.axislist.items():
ax.clear()
self.axislist = {}
# self.stopEdit()
#print "TimeSeries: ", dir(self.timeSeries), type(self.timeSeries)
#plt.cla()
#plt.clf()
self.timeSeries.plot([], [], picker=5)
def stopEdit(self):
self.clear()
self.selectedlist = None
self.selplot = None
self.lman = None
#self.canvas.mpl_disconnect(self.hoverAction)
try:
self.canvas.mpl_disconnect(self.pointPick)
self.pointPick = None
except AttributeError as e:
logger.error(e)
self.hoverAction = None
self.xys = None
self.alpha=1
self.curveindex = -1
self.editCurve = None
# self.RefreshPlot()
if self.seriesPlotInfo and self.seriesPlotInfo.isPlotted(self.editseriesID):
self.updatePlot()
self.toolbar.stopEdit()
self.editseriesID = -1
def updateValues(self):
# self.addEdit(self.editCursor, self.editSeries, self.editDataFilter)
#clear current edit points and curve
if self.editCurve:
curraxis = self.axislist[self.editCurve.axisTitle]
for l in curraxis.lines:
if l.get_label() == self.editCurve.plotTitle:
curraxis.lines.remove(l)
#redraw editpoints and curve
self.seriesPlotInfo.updateEditSeries()
self.editCurve = self.seriesPlotInfo.getEditSeriesInfo()
self.drawEditPlot(self.editCurve)
self.canvas.draw()
Publisher.sendMessage("refreshTable", e=None)
示例12: PageOne
# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import mpl_disconnect [as 别名]
#.........这里部分代码省略.........
self.axes.set_xlabel("Time (s)", fontsize=12)
self.axes.set_ylabel("Voltage (mV)", fontsize=12)
self.canvas.SetInitialSize(size=(600, 600))
self.add_toolbar()
self.cidUpdate = self.canvas.mpl_connect(
'motion_notify_event', self.UpdateStatusBar)
plot_sizer.Add(self.toolbar, 0, wx.CENTER)
plot_sizer.Add(self.canvas, 0, wx.ALL)
horizontal_sizer.Add(self.input_sizer, 0, wx.CENTRE)
horizontal_sizer.Add(self.output_sizer, 0, wx.EXPAND)
horizontal_sizer.Add(self.export_sizer, 0, wx.EXPAND)
main_sizer.Add(horizontal_sizer, 0, wx.ALL, border=10)
main_sizer.Add(plot_sizer, 0, wx.ALL)
self.SetSizerAndFit(main_sizer)
self.data_packet = []
self.x = []
self.y = []
# Create a publisher receiver
pub.subscribe(self.new_data, "newdata")
pub.subscribe(self.clear_canvas, "clearcanvas")
def new_data(self, msg):
data = msg.data
if isinstance(msg.data, float):
self.input_value.Clear()
self.input_value.AppendText(str(data))
if(self.toolbar.mode == "pan/zoom"):
return
if(self.toolbar.mode == "zoom rect"):
return
self.canvas.mpl_disconnect(self.frame.page_1.cidUpdate)
self.axes.cla()
self.axes.grid(color='gray', linestyle='dashed')
self.axes.plot(self.y, self.x)
self.canvas.draw()
self.cidUpdate = self.frame.page_1.canvas.mpl_connect(
'motion_notify_event', self.frame.page_1.UpdateStatusBar)
def clear_canvas(self, msg):
self.input_value.Clear()
self.axes.cla()
self.axes.grid(color='gray', linestyle='dashed')
self.axes.plot(self.y, self.x)
self.canvas.draw()
def UpdateStatusBar(self, event):
if event.inaxes:
x, y = event.xdata, event.ydata
self.frame.status_bar.SetStatusText(
("x= " + "%.4g" % x + " y=" + "%.4g" % y), 1)
def add_toolbar(self):
self.toolbar = MyCustomToolbar(self.canvas)
self.toolbar.Realize()
# On Windows platform, default window size is incorrect, so set
# toolbar width to figure width.
tw, th = self.toolbar.GetSizeTuple()
fw, fh = self.canvas.GetSizeTuple()
# By adding toolbar in sizer, we are able to put it at the bottom
# of the frame - so appearance is closer to GTK version.
# As noted above, doesn't work for Mac.
self.toolbar.SetSize(wx.Size(fw, th))
#self.main_sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)