本文整理汇总了Python中matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg.update方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2WxAgg.update方法的具体用法?Python NavigationToolbar2WxAgg.update怎么用?Python NavigationToolbar2WxAgg.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg
的用法示例。
在下文中一共展示了NavigationToolbar2WxAgg.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlotPanel
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import update [as 别名]
class PlotPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
self.fig = Figure((5, 4), 75)
self.canvas = FigureCanvas(self, -1, self.fig)
self.toolbar = NavigationToolbar(self.canvas) # matplotlib toolbar
self.toolbar.Realize()
# self.toolbar.set_active([0,1])
# Now put all into a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
# This way of adding to sizer allows resizing
sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
# Best to allow the toolbar to resize!
sizer.Add(self.toolbar, 0, wx.GROW)
self.SetSizer(sizer)
self.Fit()
def init_plot_data(self):
a = self.fig.add_subplot(111)
x = np.arange(120.0) * 2 * np.pi / 60.0
y = np.arange(100.0) * 2 * np.pi / 50.0
self.x, self.y = np.meshgrid(x, y)
z = np.sin(self.x) + np.cos(self.y)
self.im = a.imshow(z, cmap=cm.RdBu) # , interpolation='nearest')
zmax = np.max(z) - ERR_TOL
ymax_i, xmax_i = np.nonzero(z >= zmax)
if self.im.origin == 'upper':
ymax_i = z.shape[0] - ymax_i
self.lines = a.plot(xmax_i, ymax_i, 'ko')
self.toolbar.update() # Not sure why this is needed - ADS
def GetToolBar(self):
# You will need to override GetToolBar if you are using an
# unmanaged toolbar in your frame
return self.toolbar
def OnWhiz(self, evt):
self.x += np.pi / 15
self.y += np.pi / 20
z = np.sin(self.x) + np.cos(self.y)
self.im.set_array(z)
zmax = np.max(z) - ERR_TOL
ymax_i, xmax_i = np.nonzero(z >= zmax)
if self.im.origin == 'upper':
ymax_i = z.shape[0] - ymax_i
self.lines[0].set_data(xmax_i, ymax_i)
self.canvas.draw()
示例2: Plots_Panel
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import update [as 别名]
class Plots_Panel(wx.Panel):
"""
Panel to hold matplotlib figure. There are three plots inside a grid, big one
for temperature vs. deformation and smaller ones for time vs. deformation and
time vs. temperature.
"""
#--------------------------------------------------------------------------#
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.init_plots() #make figure
self.PlotsCanvas = FigCanvas(self, wx.ID_ANY, self.fig)
self.toolbar = NavigationToolbar(self.PlotsCanvas)
self.toolbar.Realize()
#correct toolbar size
tw, th = self.toolbar.GetSizeTuple()
fw, fh = self.PlotsCanvas.GetSizeTuple()
# Sizers
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.PlotsCanvas, 1, wx.EXPAND | wx.GROW)
sizer.Add(self.toolbar, 0, wx.BOTTOM | wx.GROW)
self.toolbar.SetSize(wx.Size(fw, th))
self.toolbar.update()
self.SetSizerAndFit(sizer)
#--------------------------------------------------------------------------#
def init_plots(self):
self.fig = Figure((-1,7.5))
self.fig.subplots_adjust(left=0.05, wspace=.3, hspace=3) #sub plot spacing
gs = matplotlib.gridspec.GridSpec(8,3)
self.ax1 = self.fig.add_subplot(gs[:,0:2])
self.ax2 = self.fig.add_subplot(gs[0:4,2])
self.ax3 = self.fig.add_subplot(gs[4:8,2])
self.ax1.set_xlabel(u'Temperatura ($^\circ$C)')
self.ax1.set_ylabel(u'Deformación (mm)')
self.ax2.set_xlabel(u'Tiempo (s)')
self.ax2.set_ylabel(u'Deformación (mm)')
self.ax3.set_xlabel(u'Tiempo (s)')
self.ax3.set_ylabel(u'Temperatura ($^\circ$C)')
示例3: AddToolbar
# 需要导入模块: from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.NavigationToolbar2WxAgg import update [as 别名]
def AddToolbar(parent,sizer):
toolbar = NavigationToolbar(parent)
toolbar.Realize()
if wx.Platform == '__WXMAC__':
# Mac platform (OSX 10.3, MacPython) does not seem to cope with
# having a toolbar in a sizer. This work-around gets the buttons
# back, but at the expense of having the toolbar at the top
parent.SetToolBar(toolbar)
else:
# On Windows platform, default window size is incorrect, so set
# toolbar width to figure width.
tw, th = toolbar.GetSizeTuple()
fw, fh = parent.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.
toolbar.SetSize(wx.Size(fw, th))
sizer.Add(toolbar, 0, wx.LEFT | wx.EXPAND)
# update the axes menu on the toolbar
toolbar.update()
return toolbar