本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setToolTip方法的具体用法?Python FigureCanvasQTAgg.setToolTip怎么用?Python FigureCanvasQTAgg.setToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.setToolTip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StreamViewerWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setToolTip [as 别名]
class StreamViewerWidget(QtGui.QWidget):
"""Shows the entire signal and allows the user to navigate through it.
Provides an scrollable selector over the entire signal.
Attributes:
xmin: Selector lower limit (measured in h-axis units).
xmax: Selector upper limit (measured in h-axis units).
step: Selector length (measured in h-axis units).
"""
trace_selected = QtCore.Signal(int)
selection_made = QtCore.Signal(bool)
def __init__(self, parent, stream=None):
super(StreamViewerWidget, self).__init__(parent)
self.fig = plt.figure()
self.canvas = FigureCanvas(self.fig)
self.canvas.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Expanding,
QtGui.QSizePolicy.Policy.Expanding))
self.canvas.setMinimumHeight(320)
self.canvas.setFocusPolicy(QtCore.Qt.ClickFocus)
self.canvas.setFocus()
self.graphArea = QtGui.QScrollArea(self)
self.graphArea.setWidget(self.canvas)
self.graphArea.setWidgetResizable(True)
self.graphArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
# Set the layout
self.layout = QtGui.QVBoxLayout(self)
self.layout.addWidget(self.graphArea)
# Animation related attrs.
self.background = []
self.animated = False
self.size = (self.fig.bbox.width, self.fig.bbox.height)
# Set TracePlot list
self.trace_plots = []
self.stream = None
if stream is not None:
self.set_stream(stream)
# Event handling
self.visible_axes = []
self._selected_traces = set()
self.shift_pressed = False
self.press_selector = None
self.fig.canvas.mpl_connect('motion_notify_event', self.on_move)
self.fig.canvas.mpl_connect('button_press_event', self.on_press)
self.fig.canvas.mpl_connect('key_press_event', self.on_key_press)
self.fig.canvas.mpl_connect('key_release_event', self.on_key_release)
@property
def selected_traces(self):
if self.stream is not None:
return [self.stream.traces[i] for i in self._selected_traces]
return []
def on_move(self, event):
axes_selected = False
for i, axes in enumerate(self.fig.axes):
if axes.get_visible():
ymin, ymax = axes.get_position().ymin, axes.get_position().ymax
xmin, xmax = axes.get_position().xmin, axes.get_position().xmax
xfig, yfig = self._event_to_fig_coords(event)
if ymin <= yfig <= ymax and xmin <= xfig <= xmax:
self.canvas.setToolTip(self.stream.traces[i].name)
axes_selected = True
break
if not axes_selected:
self.canvas.setToolTip("")
def on_key_press(self, event):
if event.key == 'control':
self.shift_pressed = True
def on_key_release(self, event):
self.shift_pressed = False
def on_press(self, event):
trace_selected = False
if event.button == 1:# and event.dblclick:
for i, ax in enumerate(self.fig.axes):
if ax.get_visible():
ymin, ymax = ax.get_position().ymin, ax.get_position().ymax
xmin, xmax = ax.get_position().xmin, ax.get_position().xmax
xfig, yfig = self._event_to_fig_coords(event)
if ymin <= yfig <= ymax and xmin <= xfig <= xmax:
trace_selected = True
if self.shift_pressed:
if self._selected_traces:
self.trace_selected.emit(i)
self.selection_made.emit(True)
self._selected_traces.add(i)
else:
self.trace_selected.emit(i)
self.selection_made.emit(True)
self._selected_traces = {i}
#.........这里部分代码省略.........