本文整理汇总了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]
#.........这里部分代码省略.........