本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.clearMask方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.clearMask方法的具体用法?Python FigureCanvasQTAgg.clearMask怎么用?Python FigureCanvasQTAgg.clearMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.clearMask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MplGraphWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import clearMask [as 别名]
class MplGraphWidget(QtGui.QWidget):
def __init__(self, parent=None, width=3, height=3, dpi=100):
super(MplGraphWidget, self).__init__(parent)
self._dataY = np.array([])
self._dataX = np.array([])
self._spCols = 1
self._spRows = 1
self.all_sp_axes = []
self.fig = Figure(figsize=(width,height), dpi=dpi)
self.all_sp_axes.append(self.fig.add_subplot(self._spCols, self._spRows, 1))
self.fig.set_frameon(False)
self.fig.set_tight_layout(True)
self.canvas = Canvas(self.fig)
self._navBarOn = True
self.mpl_toolbar = NavigationToolbar(self.canvas, parent)
self.canvas.mpl_connect('key_press_event', self.on_key_press)
self.canvas.mpl_connect('button_press_event', self.on_button_press)
self.canvas.mpl_connect('motion_notify_event', self.on_mouse_move)
self.canvas.setFocusPolicy(QtCore.Qt.ClickFocus)
self.canvas.setFocus()
self.canvas.setParent(parent)
self.canvas.clearMask()
self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.canvas.updateGeometry()
vbox = QtGui.QVBoxLayout()
vbox.addWidget(self.canvas)
if self._navBarOn:
vbox.addWidget(self.mpl_toolbar)
self.setLayout(vbox)
key_pressed = QtCore.pyqtSignal(object, name='keyPressed')
def on_key_press(self, event):
self.key_pressed.emit(event)
key_press_handler(event, self.canvas, self.mpl_toolbar)
button_pressed = QtCore.pyqtSignal(object, name='buttonPressed')
def on_button_press(self, event):
self.button_pressed.emit(event)
key_press_handler(event, self.canvas, self.mpl_toolbar)
mouse_move = QtCore.pyqtSignal(object, name='mouseMoved')
def on_mouse_move(self, event):
self.mouse_move.emit(event)
key_press_handler(event, self.canvas, self.mpl_toolbar)
def get_icon(name):
"""Return Matplotlib icon *name*"""
return QtGui.QIcon(osp.join(rcParams['datapath'], 'images', name))
def generateNewAxes(self):
for ax in self.all_sp_axes:
self.fig.delaxes(ax)
self.all_sp_axes = []
numOfAxes = (self._spRows*self._spCols)+1
for i in np.arange(1,numOfAxes):
self.all_sp_axes.append(self.fig.add_subplot(self._spRows, self._spCols, i))
self.canvas.setGeometry(100, 100, 300, 300) #Used to update the new number of axes
self.canvas.updateGeometry() #This will bring the size of the canvas back to the original (defined by the vbox)
spRowsChanged = QtCore.pyqtSignal(int)
def getspRows(self):
return self._spRows
@QtCore.pyqtSlot(int)
def setspRows(self, spRows):
self._spRows = spRows
self.generateNewAxes()
self.spRowsChanged.emit(spRows)
def resetspRows(self):
self.setspRows(1)
spRows = QtCore.pyqtProperty(int, getspRows, setspRows, resetspRows)
spColsChanged = QtCore.pyqtSignal(int)
def getspCols(self):
return self._spCols
@QtCore.pyqtSlot(int)
def setspCols(self, spCols):
self._spCols = spCols
self.generateNewAxes()
self.spRowsChanged.emit(spCols)
def resetspCols(self):
self.setspCols(1)
#.........这里部分代码省略.........