本文整理匯總了Python中matplotlib.backends.backend_wx.FigureCanvasWx.mpl_connect方法的典型用法代碼示例。如果您正苦於以下問題:Python FigureCanvasWx.mpl_connect方法的具體用法?Python FigureCanvasWx.mpl_connect怎麽用?Python FigureCanvasWx.mpl_connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.backends.backend_wx.FigureCanvasWx
的用法示例。
在下文中一共展示了FigureCanvasWx.mpl_connect方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: CanvasFrame
# 需要導入模塊: from matplotlib.backends.backend_wx import FigureCanvasWx [as 別名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import mpl_connect [as 別名]
class CanvasFrame(wx.Frame):
"""create a main plotting canvas
title : optional window title
as_one : plot as one overlapping graph
(else a list of scaled graphs)
verb : verbose level (default 1)
"""
counter = 0
def __init__(self, title="", as_one=0, verb=1):
wx.Frame.__init__(self, None, -1, title, size=(400, 300))
self.counter += 1
self.verb = verb
self.figure = Figure()
self.canvas = FigureCanvas(self, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()
self.canvas.mpl_connect("key_press_event", self.cb_keypress)
self.as_one = as_one
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar.Realize()
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
self.toolbar.update()
def cb_keypress(self, event):
if event.key == "q":
self.Close()
def plot_scaled_mat(self, amat, verb=1):
"""plot data scaled and shifted to fit on one graph
data - AfniMatrix, list of float lists, or 1D file
title - optional window title
verb - optional verbose level
"""
# allow matlist, list of float lists,
# if type(matlist) == type([]):
# e0 = matlist[0]
# if type
if not matlist:
return
nmats = len(matlist)
if nmats < 1:
return
yformat = FormatStrFormatter("%5.1f")
def plot_matlist(self, matlist, title="", ylabels=[], ftcolors=0, verb=1):
"""plot AfniMatrix list, one graph per AfniMatrix
matlist - list of AfniMatrix elements
title - optional window title
ylabels - optional list of ylabel per mat
ftcolors - flag: use fit/timeseries colors (black blue)
verb - optional verbose level
"""
if not matlist:
return
nmats = len(matlist)
if nmats < 1:
return
yformat = FormatStrFormatter("%5.1f")
matplotlib.rcParams["lines.linewidth"] = 2
# make a label list, and get max length (among any label[0])
if ylabels:
labels = ylabels
else:
labels = []
rlen = 0
nruns = 0
maxlen = 0
for ind in range(nmats):
if ylabels:
lab = ylabels[ind]
else:
if matlist[ind].labels:
lab = matlist[ind].labels[0]
else:
lab = ""
labels.append(lab)
if len(lab) > maxlen:
maxlen = len(lab)
# note run info
if nruns == 0 and matlist[ind].nruns > 1:
nruns = matlist[ind].nruns
rlen = matlist[ind].run_len
for ind in range(nmats):
amat = matlist[ind]
#.........這裏部分代碼省略.........