pylab_ml.gui.instruments.softscope.softscope.Scope
- class Scope(gui, frame=None, width=5, height=5, dpi=100, min_y=None, max_y=None, bgcolor=None)[source]
Bases:
FigureCanvasQTAggScope class for the softscope instrument, responsible for plotting data in real-time. It uses Matplotlib to create a dynamic plot that updates with new data points. The class handles the initialization of the plot, updating the data, and adjusting the axes as needed.
- __init__(gui, frame=None, width=5, height=5, dpi=100, min_y=None, max_y=None, bgcolor=None)[source]
Initialize the Scope class with the given parameters and set up the Matplotlib figure and axes for plotting.
- Parameters:
gui (object) – The GUI instance to which this scope belongs.
frame (object, optional) – The frame in which the scope will be displayed.
width (int, optional) – The width of the figure in inches.
height (int, optional) – The height of the figure in inches.
dpi (int, optional) – The dots per inch (DPI) of the figure.
min_y (float, optional) – The minimum value for the y-axis.
max_y (float, optional) – The maximum value for the y-axis.
bgcolor (str, optional) – The background color of the figure.
Methods
__init__(gui[, frame, width, height, dpi, ...])Initialize the Scope class with the given parameters and set up the Matplotlib figure and axes for plotting.
acceptDrops(self)accessibleDescription(self)accessibleName(self)actionEvent(self, a0)actions(self)activateWindow(self)addAction(self, action)addActions(self, actions)adjustSize(self)autoFillBackground(self)backgroundRole(self)baseSize(self)blit([bbox])Blit the canvas in bbox (default entire canvas).
blockSignals(self, b)Get the image as a memoryview to the renderer's buffer.
changeEvent(self, a0)childAt(-> Optional[QWidget])childEvent(self, a0)children(self)childrenRect(self)childrenRegion(self)clear()Clear the scope and reset all relevant parameters.
clearFocus(self)clearMask(self)close(self)closeEvent(self, a0)colorCount(self)connectNotify(self, signal)contentsMargins(self)contentsRect(self)contextMenuEvent(self, a0)contextMenuPolicy(self)copy_from_bbox(bbox)create(self[, window, initializeWindow, ...])createWindowContainer(window[, parent, flags])cursor(self)customEvent(self, a0)deleteLater(self)depth(self)destroy(self[, destroyWindow, destroySubWindows])devType(self)devicePixelRatio(self)devicePixelRatioF(self)disconnect(-> bool)disconnectNotify(self, signal)dragEnterEvent(self, a0)dragLeaveEvent(self, a0)dragMoveEvent(self, a0)draw()Render the figure, and queue a request for a Qt draw.
drawRectangle(rect)Queue redraw of the Agg buffer and request Qt paintEvent.
dropEvent(self, a0)dumpObjectInfo(self)dumpObjectTree(self)dynamicPropertyNames(self)effectiveWinId(self)ensurePolished(self)enterEvent(self, a0)event(self, a0)eventFilter(self, a0, a1)find(a0)findChild(-> QObjectT)findChildren(...)Flush the GUI events for the figure.
focusInEvent(self, a0)focusNextChild(self)focusNextPrevChild(self, next)focusOutEvent(self, a0)focusPolicy(self)focusPreviousChild(self)focusProxy(self)focusWidget(self)font(self)fontInfo(self)fontMetrics(self)foregroundRole(self)frameGeometry(self)frameSize(self)geometry(self)getContentsMargins(self)Return a string, which includes extension, suitable for use as a default filename.
Return the default savefig file format as specified in :rc:`savefig.format`.
get_renderer()Return dict of savefig file formats supported by this backend.
Return a dict of savefig file formats supported by this backend, where the keys are a file type name, such as 'Joint Photographic Experts Group', and the values are a list of filename extensions used for that filetype, such as ['jpg', 'jpeg'].
get_width_height(*[, physical])Return the figure width and height in integral points or pixels.
grab(self[, rectangle])grabGesture(self, type[, flags])grabKeyboard(self)grabShortcut(self, key[, context])grab_mouse(ax)Set the child Axes which is grabbing the mouse events.
graphicsEffect(self)graphicsProxyWidget(self)hasFocus(self)hasHeightForWidth(self)hasMouseTracking(self)hasTabletTracking(self)height(self)heightForWidth(self, a0)heightMM(self)hide(self)hideEvent(self, a0)inaxes(xy)Return the topmost visible Axes containing the point xy.
inherits(self, classname)init()Initialization function.
initPainter(self, painter)inputMethodEvent(self, a0)inputMethodHints(self)inputMethodQuery(self, a0)insertAction(self, before, action)insertActions(self, before, actions)installEventFilter(self, a0)isActiveWindow(self)isAncestorOf(self, child)isEnabled(self)isEnabledTo(self, a0)isFullScreen(self)isHidden(self)isLeftToRight(self)isMaximized(self)isMinimized(self)isModal(self)isRightToLeft(self)isSignalConnected(self, signal)isVisible(self)isVisibleTo(self, a0)isWidgetType(self)isWindow(self)isWindowModified(self)isWindowType(self)Return whether the renderer is in the process of saving to a file, rather than rendering for an on-screen buffer.
keyPressEvent(self, a0)keyReleaseEvent(self, a0)killTimer(self, id)layout(self)layoutDirection(self)leaveEvent(self, a0)locale(self)logicalDpiX(self)logicalDpiY(self)lower(self)mapFrom(self, a0, a1)mapFromGlobal(self, a0)mapFromParent(self, a0)mapTo(self, a0, a1)mapToGlobal(self, a0)mapToParent(self, a0)mask(self)maximumHeight(self)maximumSize(self)maximumWidth(self)metaObject(self)metric(self, a0)minimumHeight(self)minimumSize(self)minimumSizeHint(self)minimumWidth(self)mouseDoubleClickEvent(self, a0)mouseEventCoords([pos])Calculate mouse coordinates in physical pixels.
mouseMoveEvent(self, a0)mousePressEvent(self, a0)mouseReleaseEvent(self, a0)move()moveEvent(self, a0)moveToThread(self, thread)mpl_connect(s, func)Bind function func to event s.
mpl_disconnect(cid)Disconnect the callback with id cid.
nativeEvent(self, eventType, message)nativeParentWidget(self)new_manager(figure, num)Create a new figure manager for figure, using this canvas class.
new_timer([interval, callbacks])Create a new backend-specific subclass of Timer.
newdata(y)Update the scope with new data.
nextInFocusChain(self)normalGeometry(self)objectName(self)overrideWindowFlags(self, type)overrideWindowState(self, state)paintEngine(self)paintEvent(event)Copy the image from the Agg canvas to the qt.drawable.
paintingActive(self)palette(self)parent(self)parentWidget(self)physicalDpiX(self)physicalDpiY(self)pos(self)previousInFocusChain(self)print_figure(*args, **kwargs)Render the figure to hardcopy.
print_jpeg(filename_or_obj, *[, metadata, ...])Write the figure to a JPEG file.
print_jpg(filename_or_obj, *[, metadata, ...])Write the figure to a JPEG file.
print_png(filename_or_obj, *[, metadata, ...])Write the figure to a PNG file.
print_raw(filename_or_obj, *[, metadata])print_rgba(filename_or_obj, *[, metadata])print_tif(filename_or_obj, *[, metadata, ...])Write the figure to a TIFF file.
print_tiff(filename_or_obj, *[, metadata, ...])Write the figure to a TIFF file.
print_to_buffer()print_webp(filename_or_obj, *[, metadata, ...])Write the figure to a WebP file.
property(self, name)pyqtConfigure(...)Each keyword argument is either the name of a Qt property or a Qt signal.
raise_(self)receivers(self, signal)rect(self)releaseKeyboard(self)releaseMouse(self)releaseShortcut(self, id)release_mouse(ax)Release the mouse grab held by the Axes ax.
removeAction(self, action)removeEventFilter(self, a0)render(, sourceRegion, flags, ...)repaint(-> None -> None)resize()resizeEvent(self, a0)restoreGeometry(self, geometry)restore_region(region[, bbox, xy])saveGeometry(self)screen(self)scroll()sender(self)senderSignalIndex(self)setAcceptDrops(self, on)setAccessibleDescription(self, description)setAccessibleName(self, name)setAttribute(self, attribute[, on])setAutoFillBackground(self, enabled)setBackgroundRole(self, a0)setContextMenuPolicy(self, policy)setCursor(self, a0)setDisabled(self, a0)setEnabled(self, a0)setFixedHeight(self, h)setFixedWidth(self, w)setFocus()setFocusPolicy(self, policy)setFocusProxy(self, a0)setFont(self, a0)setForegroundRole(self, a0)setGraphicsEffect(self, effect)setHidden(self, hidden)setInputMethodHints(self, hints)setLayout(self, a0)setLayoutDirection(self, direction)setLocale(self, locale)setMask()setMaximumHeight(self, maxh)setMaximumWidth(self, maxw)setMinimumHeight(self, minh)setMinimumWidth(self, minw)setMouseTracking(self, enable)setObjectName(self, name)setPalette(self, a0)setProperty(self, name, value)setShortcutAutoRepeat(self, id[, enabled])setShortcutEnabled(self, id[, enabled])setStatusTip(self, a0)setStyle(self, a0)setStyleSheet(self, styleSheet)setTabOrder(a0, a1)setTabletTracking(self, enable)setToolTip(self, a0)setToolTipDuration(self, msec)setUpdatesEnabled(self, enable)setVisible(self, visible)setWhatsThis(self, a0)setWindowFilePath(self, filePath)setWindowFlag(self, a0[, on])setWindowFlags(self, type)setWindowIcon(self, icon)setWindowIconText(self, a0)setWindowModality(self, windowModality)setWindowModified(self, a0)setWindowOpacity(self, level)setWindowRole(self, a0)setWindowState(self, state)setWindowTitle(self, a0)set_cursor(cursor)Set the current cursor.
setrange()Adjust the y-axis range based on the current minimum and maximum y values.
sharedPainter(self)show(self)showEvent(self, a0)showFullScreen(self)showMaximized(self)showMinimized(self)showNormal(self)signalsBlocked(self)size(self)sizeHint(self)sizeIncrement(self)sizePolicy(self)stackUnder(self, a0)startTimer(self, interval[, timerType])start_event_loop([timeout])Start a blocking event loop.
statusTip(self)stop_event_loop([event])Stop the current blocking event loop.
style(self)styleSheet(self)switch_backends(FigureCanvasClass)[Deprecated] Instantiate an instance of FigureCanvasClass
tabletEvent(self, a0)testAttribute(self, attribute)thread(self)timerEvent(self, a0)toolTip(self)toolTipDuration(self)Get the image as ARGB bytes.
[Deprecated] Get the image as RGB bytes.
tr(self, sourceText[, disambiguation, n])underMouse(self)ungrabGesture(self, type)unsetCursor(self)unsetLayoutDirection(self)unsetLocale(self)update(-> None -> None)updateGeometry(self)updateMicroFocus(self)updatesEnabled(self)visibleRegion(self)whatsThis(self)wheelEvent(self, a0)width(self)widthMM(self)winId(self)window(self)windowFilePath(self)windowFlags(self)windowHandle(self)windowIcon(self)windowIconText(self)windowModality(self)windowOpacity(self)windowRole(self)windowState(self)windowTitle(self)windowType(self)x(self)y(self)Attributes
DrawChildrenDrawWindowBackgroundIgnoreMaskPdmDepthPdmDevicePixelRatioPdmDevicePixelRatioScaledPdmDpiXPdmDpiYPdmHeightPdmHeightMMPdmNumColorsPdmPhysicalDpiXPdmPhysicalDpiYPdmWidthPdmWidthMMbutton_pick_idbuttondcallbacksQPoint) [signal]
Optional[QObject] = None) [signal]
The ratio of physical to logical pixels used for the canvas on screen.
eventsfiletypesfixed_dpiMaximum samples.
Get the current maximum y value of the scope.
Get the current minimum y value of the scope.
Optional[str]) [signal]
required_interactive_frameworksampleStepsGet the current sample rate of the scope.
Get the current number of samples in the scope.
scroll_pick_idstaticMetaObjectsupports_blitGet the current value of the scope.
QIcon) [signal]
Optional[str]) [signal]
Optional[str]) [signal]
- class PaintDeviceMetric
Bases:
int
- class RenderFlag
Bases:
int
- class RenderFlags
- class RenderFlags(f: QWidget.RenderFlags | QWidget.RenderFlag)
- class RenderFlags(a0: QWidget.RenderFlags)
Bases:
simplewrapper
- acceptDrops(self) bool
- accessibleDescription(self) str
- accessibleName(self) str
- actionEvent(self, a0: QActionEvent | None)
- actions(self) List[QAction]
- activateWindow(self)
- addAction(self, action: QAction | None)
- addActions(self, actions: Iterable[QAction])
- adjustSize(self)
- autoFillBackground(self) bool
- backgroundRole(self) QPalette.ColorRole
- baseSize(self) QSize
- blit(bbox=None)
Blit the canvas in bbox (default entire canvas).
- blockSignals(self, b: bool) bool
- buffer_rgba()
Get the image as a memoryview to the renderer’s buffer.
drawmust be called at least once before this function will work and to update the renderer for any subsequent changes to the Figure.
- changeEvent(self, a0: QEvent | None)
- childAt(self, p: QPoint) QWidget | None
- childAt(self, ax: int, ay: int) QWidget | None
- childEvent(self, a0: QChildEvent | None)
- children(self) List[QObject]
- childrenRect(self) QRect
- childrenRegion(self) QRegion
- clearFocus(self)
- clearMask(self)
- close(self) bool
- closeEvent(self, a0: QCloseEvent | None)
- colorCount(self) int
- connectNotify(self, signal: QMetaMethod)
- contentsMargins(self) QMargins
- contentsRect(self) QRect
- contextMenuEvent(self, a0: QContextMenuEvent | None)
- contextMenuPolicy(self) Qt.ContextMenuPolicy
- create(self, window: PyQt5.sip.voidptr = None, initializeWindow: bool = True, destroyOldWindow: bool = True)
- createWindowContainer(window: QWindow | None, parent: QWidget | None = None, flags: Qt.WindowFlags | Qt.WindowType = 0) QWidget
- cursor(self) QCursor
- customContextMenuRequested
QPoint) [signal]
- Type:
customContextMenuRequested(self, pos
- customEvent(self, a0: QEvent | None)
- deleteLater(self)
- depth(self) int
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
- destroyed
Optional[QObject] = None) [signal]
- Type:
destroyed(self, object
- devType(self) int
- devicePixelRatio(self) int
- devicePixelRatioF(self) float
- devicePixelRatioFScale() float
- property device_pixel_ratio
The ratio of physical to logical pixels used for the canvas on screen.
By default, this is 1, meaning physical and logical pixels are the same size. Subclasses that support High DPI screens may set this property to indicate that said ratio is different. All Matplotlib interaction, unless working directly with the canvas, remains in logical pixels.
- disconnect(a0: QMetaObject.Connection) bool
- disconnect(self) None
- disconnectNotify(self, signal: QMetaMethod)
- dragEnterEvent(self, a0: QDragEnterEvent | None)
- dragLeaveEvent(self, a0: QDragLeaveEvent | None)
- dragMoveEvent(self, a0: QDragMoveEvent | None)
- draw()
Render the figure, and queue a request for a Qt draw.
- draw_idle()
Queue redraw of the Agg buffer and request Qt paintEvent.
- dropEvent(self, a0: QDropEvent | None)
- dumpObjectInfo(self)
- dumpObjectTree(self)
- dynamicPropertyNames(self) List[QByteArray]
- effectiveWinId(self) PyQt5.sip.voidptr
- ensurePolished(self)
- enterEvent(self, a0: QEvent | None)
- event(self, a0: QEvent | None) bool
- eventFilter(self, a0: QObject | None, a1: QEvent | None) bool
- find(a0: PyQt5.sip.voidptr) QWidget | None
- findChild(self, type: Type[QObjectT], name: str | None = '', options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) QObjectT
- findChild(self, types: Tuple[Type[QObjectT], ...], name: str | None = '', options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) QObjectT
- findChildren(self, type: Type[QObjectT], name: str | None = '', options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObjectT]
- findChildren(self, types: Tuple[Type[QObjectT], ...], name: str | None = '', options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObjectT]
- findChildren(self, type: Type[QObjectT], regExp: QRegExp, options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObjectT]
- findChildren(self, types: Tuple[Type[QObjectT], ...], regExp: QRegExp, options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObjectT]
- findChildren(self, type: Type[QObjectT], re: QRegularExpression, options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObjectT]
- findChildren(self, types: Tuple[Type[QObjectT], ...], re: QRegularExpression, options: Qt.FindChildOptions | Qt.FindChildOption = Qt.FindChildrenRecursively) List[QObjectT]
- flush_events()
Flush the GUI events for the figure.
Interactive backends need to reimplement this method.
- focusInEvent(self, a0: QFocusEvent | None)
- focusNextChild(self) bool
- focusNextPrevChild(self, next: bool) bool
- focusOutEvent(self, a0: QFocusEvent | None)
- focusPolicy(self) Qt.FocusPolicy
- focusPreviousChild(self) bool
- focusProxy(self) QWidget | None
- focusWidget(self) QWidget | None
- font(self) QFont
- fontInfo(self) QFontInfo
- fontMetrics(self) QFontMetrics
- foregroundRole(self) QPalette.ColorRole
- frameGeometry(self) QRect
- frameSize(self) QSize
- geometry(self) QRect
- getContentsMargins(self)
- get_default_filename()
Return a string, which includes extension, suitable for use as a default filename.
- classmethod get_default_filetype()
Return the default savefig file format as specified in :rc:`savefig.format`.
The returned string does not include a period. This method is overridden in backends that only support a single file type.
- classmethod get_supported_filetypes()
Return dict of savefig file formats supported by this backend.
- classmethod get_supported_filetypes_grouped()
Return a dict of savefig file formats supported by this backend, where the keys are a file type name, such as ‘Joint Photographic Experts Group’, and the values are a list of filename extensions used for that filetype, such as [‘jpg’, ‘jpeg’].
- get_width_height(*, physical=False)
Return the figure width and height in integral points or pixels.
When the figure is used on High DPI screens (and the backend supports it), the truncation to integers occurs after scaling by the device pixel ratio.
- Parameters:
physical (bool, default: False) – Whether to return true physical pixels or logical pixels. Physical pixels may be used by backends that support HiDPI, but still configure the canvas using its actual size.
- Returns:
width, height – The size of the figure, in points or pixels, depending on the backend.
- Return type:
int
- grab(self, rectangle: QRect = QRect(QPoint(0, 0), QSize(-1, -1))) QPixmap
- grabGesture(self, type: Qt.GestureType, flags: Qt.GestureFlags | Qt.GestureFlag = Qt.GestureFlags())
- grabKeyboard(self)
- grabMouse(self)
- grabMouse(self, a0: QCursor | Qt.CursorShape) None
- grabShortcut(self, key: QKeySequence | QKeySequence.StandardKey | str | None | int, context: Qt.ShortcutContext = Qt.WindowShortcut) int
- grab_mouse(ax)
Set the child Axes which is grabbing the mouse events.
Usually called by the widgets themselves. It is an error to call this if the mouse is already grabbed by another Axes.
- graphicsEffect(self) QGraphicsEffect | None
- graphicsProxyWidget(self) QGraphicsProxyWidget | None
- hasFocus(self) bool
- hasHeightForWidth(self) bool
- hasMouseTracking(self) bool
- hasTabletTracking(self) bool
- height(self) int
- heightForWidth(self, a0: int) int
- heightMM(self) int
- hide(self)
- hideEvent(self, a0: QHideEvent | None)
- inaxes(xy)
Return the topmost visible Axes containing the point xy.
- Parameters:
xy ((float, float)) – (x, y) pixel positions from left/bottom of the canvas.
- Returns:
The topmost visible Axes containing the point, or None if there is no Axes at the point.
- Return type:
Axesor None
- inherits(self, classname: str | None) bool
- initPainter(self, painter: QPainter | None)
- inputMethodEvent(self, a0: QInputMethodEvent | None)
- inputMethodHints(self) Qt.InputMethodHints
- inputMethodQuery(self, a0: Qt.InputMethodQuery) Any
- insertAction(self, before: QAction | None, action: QAction | None)
- insertActions(self, before: QAction | None, actions: Iterable[QAction])
- installEventFilter(self, a0: QObject | None)
- isActiveWindow(self) bool
- isAncestorOf(self, child: QWidget | None) bool
- isEnabled(self) bool
- isEnabledTo(self, a0: QWidget | None) bool
- isFullScreen(self) bool
- isHidden(self) bool
- isLeftToRight(self) bool
- isMaximized(self) bool
- isMinimized(self) bool
- isModal(self) bool
- isRightToLeft(self) bool
- isSignalConnected(self, signal: QMetaMethod) bool
- isVisible(self) bool
- isVisibleTo(self, a0: QWidget | None) bool
- isWidgetType(self) bool
- isWindow(self) bool
- isWindowModified(self) bool
- isWindowType(self) bool
- is_saving()
Return whether the renderer is in the process of saving to a file, rather than rendering for an on-screen buffer.
- keyPressEvent(self, a0: QKeyEvent | None)
- keyReleaseEvent(self, a0: QKeyEvent | None)
- keyboardGrabber() QWidget | None
- killTimer(self, id: int)
- layout(self) QLayout | None
- layoutDirection(self) Qt.LayoutDirection
- leaveEvent(self, a0: QEvent | None)
- locale(self) QLocale
- logicalDpiX(self) int
- logicalDpiY(self) int
- lower(self)
- manager_class
alias of
FigureManagerQT
- mapFrom(self, a0: QWidget | None, a1: QPoint) QPoint
- mapFromGlobal(self, a0: QPoint) QPoint
- mapFromParent(self, a0: QPoint) QPoint
- mapTo(self, a0: QWidget | None, a1: QPoint) QPoint
- mapToGlobal(self, a0: QPoint) QPoint
- mapToParent(self, a0: QPoint) QPoint
- mask(self) QRegion
- property max_x
Maximum samples.
- property max_y
Get the current maximum y value of the scope.
- maximumHeight(self) int
- maximumSize(self) QSize
- maximumWidth(self) int
- metaObject(self) QMetaObject | None
- metric(self, a0: QPaintDevice.PaintDeviceMetric) int
- property min_y
Get the current minimum y value of the scope.
- minimumHeight(self) int
- minimumSize(self) QSize
- minimumSizeHint(self) QSize
- minimumWidth(self) int
- mouseDoubleClickEvent(self, a0: QMouseEvent | None)
- mouseEventCoords(pos=None)
Calculate mouse coordinates in physical pixels.
Qt uses logical pixels, but the figure is scaled to physical pixels for rendering. Transform to physical pixels so that all of the down-stream transforms work as expected.
Also, the origin is different and needs to be corrected.
- mouseGrabber() QWidget | None
- mouseMoveEvent(self, a0: QMouseEvent | None)
- mousePressEvent(self, a0: QMouseEvent | None)
- mouseReleaseEvent(self, a0: QMouseEvent | None)
- move(self, a0: QPoint)
- move(self, ax: int, ay: int) None
- moveEvent(self, a0: QMoveEvent | None)
- moveToThread(self, thread: QThread | None)
- mpl_connect(s, func)
Bind function func to event s.
- Parameters:
s (str) –
One of the following events ids:
’button_press_event’
’button_release_event’
’draw_event’
’key_press_event’
’key_release_event’
’motion_notify_event’
’pick_event’
’resize_event’
’scroll_event’
’figure_enter_event’,
’figure_leave_event’,
’axes_enter_event’,
’axes_leave_event’
’close_event’.
func (callable) –
The callback function to be executed, which must have the signature:
def func(event: Event) -> Any
For the location events (button and key press/release), if the mouse is over the Axes, the
inaxesattribute of the event will be set to theAxesthe event occurs is over, and additionally, the variablesxdataandydataattributes will be set to the mouse location in data coordinates. See KeyEvent and MouseEvent for more info.Note
If func is a method, this only stores a weak reference to the method. Thus, the figure does not influence the lifetime of the associated object. Usually, you want to make sure that the object is kept alive throughout the lifetime of the figure by holding a reference to it.
- Returns:
A connection id that can be used with FigureCanvasBase.mpl_disconnect.
- Return type:
cid
Examples
def on_press(event): print('you pressed', event.button, event.xdata, event.ydata) cid = canvas.mpl_connect('button_press_event', on_press)
- mpl_disconnect(cid)
Disconnect the callback with id cid.
Examples
cid = canvas.mpl_connect('button_press_event', on_press) # ... later canvas.mpl_disconnect(cid)
- nativeEvent(self, eventType: QByteArray | bytes | bytearray, message: PyQt5.sip.voidptr | None)
- nativeParentWidget(self) QWidget | None
- classmethod new_manager(figure, num)
Create a new figure manager for figure, using this canvas class.
Notes
This method should not be reimplemented in subclasses. If custom manager creation logic is needed, please reimplement
FigureManager.create_with_canvas.
- new_timer(interval=None, callbacks=None)
Create a new backend-specific subclass of Timer.
This is useful for getting periodic events through the backend’s native event loop. Implemented only for backends with GUIs.
- Parameters:
interval (int) – Timer interval in milliseconds.
callbacks (list[tuple[callable, tuple, dict]]) –
Sequence of (func, args, kwargs) where
func(*args, **kwargs)will be executed by the timer every interval.Callbacks which return
Falseor0will be removed from the timer.
Examples
>>> timer = fig.canvas.new_timer(callbacks=[(f1, (1,), {'a': 3})])
- newdata(y)[source]
Update the scope with new data.
- Parameters:
y (float) – The new data point to be added to the scope.
- nextInFocusChain(self) QWidget | None
- normalGeometry(self) QRect
- objectName(self) str
- objectNameChanged
Optional[str]) [signal]
- Type:
objectNameChanged(self, objectName
- overrideWindowFlags(self, type: Qt.WindowFlags | Qt.WindowType)
- overrideWindowState(self, state: Qt.WindowStates | Qt.WindowState)
- paintEngine(self) QPaintEngine | None
- paintEvent(event)
Copy the image from the Agg canvas to the qt.drawable.
In Qt, all drawing should be done inside of here when a widget is shown onscreen.
- paintingActive(self) bool
- palette(self) QPalette
- parent(self) QObject | None
- parentWidget(self) QWidget | None
- physicalDpiX(self) int
- physicalDpiY(self) int
- pos(self) QPoint
- previousInFocusChain(self) QWidget | None
- print_figure(*args, **kwargs)
Render the figure to hardcopy. Set the figure patch face and edge colors. This is useful because some of the GUIs have a gray figure face color background and you’ll probably want to override this on hardcopy.
- Parameters:
filename (str or path-like or file-like) – The file where the figure is saved.
dpi (float, default: :rc:`savefig.dpi`) – The dots per inch to save the figure in.
facecolor (:mpltype:`color` or ‘auto’, default: :rc:`savefig.facecolor`) – The facecolor of the figure. If ‘auto’, use the current figure facecolor.
edgecolor (:mpltype:`color` or ‘auto’, default: :rc:`savefig.edgecolor`) – The edgecolor of the figure. If ‘auto’, use the current figure edgecolor.
orientation ({'landscape', 'portrait'}, default: 'portrait') – Only currently applies to PostScript printing.
format (str, optional) – Force a specific file format. If not given, the format is inferred from the filename extension, and if that fails from :rc:`savefig.format`.
bbox_inches (‘tight’ or Bbox, default: :rc:`savefig.bbox`) – Bounding box in inches: only the given portion of the figure is saved. If ‘tight’, try to figure out the tight bbox of the figure.
pad_inches (float or ‘layout’, default: :rc:`savefig.pad_inches`) – Amount of padding in inches around the figure when bbox_inches is ‘tight’. If ‘layout’ use the padding from the constrained or compressed layout engine; ignored if one of those engines is not in use.
bbox_extra_artists (list of
Artist, optional) – A list of extra artists that will be considered when the tight bbox is calculated.backend (str, optional) – Use a non-default backend to render the file, e.g. to render a png file with the “cairo” backend rather than the default “agg”, or a pdf file with the “pgf” backend rather than the default “pdf”. Note that the default backend is normally sufficient. See the-builtin-backends for a list of valid backends for each file format. Custom backends can be referenced as “module://…”.
- print_jpeg(filename_or_obj, *, metadata=None, pil_kwargs=None)
Write the figure to a JPEG file.
- Parameters:
filename_or_obj (str or path-like or file-like) – The file to write to.
pil_kwargs (dict, optional) – Additional keyword arguments that are passed to
PIL.Image.Image.savewhen saving the figure.
- print_jpg(filename_or_obj, *, metadata=None, pil_kwargs=None)
Write the figure to a JPEG file.
- Parameters:
filename_or_obj (str or path-like or file-like) – The file to write to.
pil_kwargs (dict, optional) – Additional keyword arguments that are passed to
PIL.Image.Image.savewhen saving the figure.
- print_png(filename_or_obj, *, metadata=None, pil_kwargs=None)
Write the figure to a PNG file.
- Parameters:
filename_or_obj (str or path-like or file-like) – The file to write to.
metadata (dict, optional) –
Metadata in the PNG file as key-value pairs of bytes or latin-1 encodable strings. According to the PNG specification, keys must be shorter than 79 chars.
The PNG specification defines some common keywords that may be used as appropriate:
Title: Short (one line) title or caption for image.
Author: Name of image’s creator.
Description: Description of image (possibly long).
Copyright: Copyright notice.
Creation Time: Time of original image creation (usually RFC 1123 format).
Software: Software used to create the image.
Disclaimer: Legal disclaimer.
Warning: Warning of nature of content.
Source: Device used to create the image.
Comment: Miscellaneous comment; conversion from other image format.
Other keywords may be invented for other purposes.
If ‘Software’ is not given, an autogenerated value for Matplotlib will be used. This can be removed by setting it to None.
For more details see the PNG specification.
pil_kwargs (dict, optional) –
Keyword arguments passed to
PIL.Image.Image.save.If the ‘pnginfo’ key is present, it completely overrides metadata, including the default ‘Software’ key.
- print_tif(filename_or_obj, *, metadata=None, pil_kwargs=None)
Write the figure to a TIFF file.
- Parameters:
filename_or_obj (str or path-like or file-like) – The file to write to.
pil_kwargs (dict, optional) – Additional keyword arguments that are passed to
PIL.Image.Image.savewhen saving the figure.
- print_tiff(filename_or_obj, *, metadata=None, pil_kwargs=None)
Write the figure to a TIFF file.
- Parameters:
filename_or_obj (str or path-like or file-like) – The file to write to.
pil_kwargs (dict, optional) – Additional keyword arguments that are passed to
PIL.Image.Image.savewhen saving the figure.
- print_webp(filename_or_obj, *, metadata=None, pil_kwargs=None)
Write the figure to a WebP file.
- Parameters:
filename_or_obj (str or path-like or file-like) – The file to write to.
pil_kwargs (dict, optional) – Additional keyword arguments that are passed to
PIL.Image.Image.savewhen saving the figure.
- property(self, name: str | None) Any
- pyqtConfigure(...)
Each keyword argument is either the name of a Qt property or a Qt signal. For properties the property is set to the given value which should be of an appropriate type. For signals the signal is connected to the given value which should be a callable.
- raise_(self)
- receivers(self, signal: PYQT_SIGNAL) int
- rect(self) QRect
- releaseKeyboard(self)
- releaseMouse(self)
- releaseShortcut(self, id: int)
- release_mouse(ax)
Release the mouse grab held by the Axes ax.
Usually called by the widgets. It is ok to call this even if ax doesn’t have the mouse grab currently.
- removeAction(self, action: QAction | None)
- removeEventFilter(self, a0: QObject | None)
- render(self, target: QPaintDevice | None, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: QWidget.RenderFlags | QWidget.RenderFlag = QWidget.RenderFlags(QWidget.RenderFlag.DrawWindowBackground | QWidget.RenderFlag.DrawChildren))
- render(self, painter: QPainter | None, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: QWidget.RenderFlags | QWidget.RenderFlag = QWidget.RenderFlags(QWidget.RenderFlag.DrawWindowBackground | QWidget.RenderFlag.DrawChildren)) None
- repaint(self)
- repaint(self, x: int, y: int, w: int, h: int) None
- repaint(self, a0: QRect) None
- repaint(self, a0: QRegion) None
- resize(self, a0: QSize)
- resize(self, w: int, h: int) None
- resizeEvent(self, a0: QResizeEvent | None)
- restoreGeometry(self, geometry: QByteArray | bytes | bytearray) bool
- property samplerate
Get the current sample rate of the scope.
- property samples
Get the current number of samples in the scope.
- saveGeometry(self) QByteArray
- screen(self) QScreen | None
- scroll(self, dx: int, dy: int)
- scroll(self, dx: int, dy: int, a2: QRect) None
- sender(self) QObject | None
- senderSignalIndex(self) int
- setAcceptDrops(self, on: bool)
- setAccessibleDescription(self, description: str | None)
- setAccessibleName(self, name: str | None)
- setAttribute(self, attribute: Qt.WidgetAttribute, on: bool = True)
- setAutoFillBackground(self, enabled: bool)
- setBackgroundRole(self, a0: QPalette.ColorRole)
- setBaseSize(self, basew: int, baseh: int)
- setBaseSize(self, s: QSize) None
- setContentsMargins(self, left: int, top: int, right: int, bottom: int)
- setContentsMargins(self, margins: QMargins) None
- setContextMenuPolicy(self, policy: Qt.ContextMenuPolicy)
- setCursor(self, a0: QCursor | Qt.CursorShape)
- setDisabled(self, a0: bool)
- setEnabled(self, a0: bool)
- setFixedHeight(self, h: int)
- setFixedSize(self, a0: QSize)
- setFixedSize(self, w: int, h: int) None
- setFixedWidth(self, w: int)
- setFocus(self)
- setFocus(self, reason: Qt.FocusReason) None
- setFocusPolicy(self, policy: Qt.FocusPolicy)
- setFocusProxy(self, a0: QWidget | None)
- setFont(self, a0: QFont)
- setForegroundRole(self, a0: QPalette.ColorRole)
- setGeometry(self, a0: QRect)
- setGeometry(self, ax: int, ay: int, aw: int, ah: int) None
- setGraphicsEffect(self, effect: QGraphicsEffect | None)
- setHidden(self, hidden: bool)
- setInputMethodHints(self, hints: Qt.InputMethodHints | Qt.InputMethodHint)
- setLayout(self, a0: QLayout | None)
- setLayoutDirection(self, direction: Qt.LayoutDirection)
- setLocale(self, locale: QLocale)
- setMask(self, a0: QBitmap)
- setMask(self, a0: QRegion) None
- setMaximumHeight(self, maxh: int)
- setMaximumSize(self, maxw: int, maxh: int)
- setMaximumSize(self, s: QSize) None
- setMaximumWidth(self, maxw: int)
- setMinimumHeight(self, minh: int)
- setMinimumSize(self, minw: int, minh: int)
- setMinimumSize(self, s: QSize) None
- setMinimumWidth(self, minw: int)
- setMouseTracking(self, enable: bool)
- setObjectName(self, name: str | None)
- setPalette(self, a0: QPalette)
- setParent(self, parent: QWidget | None)
- setParent(self, parent: QWidget | None, f: Qt.WindowFlags | Qt.WindowType) None
- setProperty(self, name: str | None, value: Any) bool
- setShortcutAutoRepeat(self, id: int, enabled: bool = True)
- setShortcutEnabled(self, id: int, enabled: bool = True)
- setSizeIncrement(self, w: int, h: int)
- setSizeIncrement(self, s: QSize) None
- setSizePolicy(self, a0: QSizePolicy)
- setSizePolicy(self, hor: QSizePolicy.Policy, ver: QSizePolicy.Policy) None
- setStatusTip(self, a0: str | None)
- setStyle(self, a0: QStyle | None)
- setStyleSheet(self, styleSheet: str | None)
- setTabOrder(a0: QWidget | None, a1: QWidget | None)
- setTabletTracking(self, enable: bool)
- setToolTip(self, a0: str | None)
- setToolTipDuration(self, msec: int)
- setUpdatesEnabled(self, enable: bool)
- setVisible(self, visible: bool)
- setWhatsThis(self, a0: str | None)
- setWindowFilePath(self, filePath: str | None)
- setWindowFlag(self, a0: Qt.WindowType, on: bool = True)
- setWindowFlags(self, type: Qt.WindowFlags | Qt.WindowType)
- setWindowIcon(self, icon: QIcon)
- setWindowIconText(self, a0: str | None)
- setWindowModality(self, windowModality: Qt.WindowModality)
- setWindowModified(self, a0: bool)
- setWindowOpacity(self, level: float)
- setWindowRole(self, a0: str | None)
- setWindowState(self, state: Qt.WindowStates | Qt.WindowState)
- setWindowTitle(self, a0: str | None)
- set_cursor(cursor)
Set the current cursor.
This may have no effect if the backend does not display anything.
If required by the backend, this method should trigger an update in the backend event loop after the cursor is set, as this method may be called e.g. before a long-running task during which the GUI is not updated.
- Parameters:
cursor (Cursors) – The cursor to display over the canvas. Note: some backends may change the cursor for the entire window.
- show(self)
- showEvent(self, a0: QShowEvent | None)
- showFullScreen(self)
- showMaximized(self)
- showMinimized(self)
- showNormal(self)
- signalsBlocked(self) bool
- size(self) QSize
- sizeHint(self) QSize
- sizeIncrement(self) QSize
- sizePolicy(self) QSizePolicy
- stackUnder(self, a0: QWidget | None)
- startTimer(self, interval: int, timerType: Qt.TimerType = Qt.CoarseTimer) int
- start_event_loop(timeout=0)
Start a blocking event loop.
Such an event loop is used by interactive functions, such as ginput and waitforbuttonpress, to wait for events.
The event loop blocks until a callback function triggers
stop_event_loop, or timeout is reached.If timeout is 0 or negative, never timeout.
Only interactive backends need to reimplement this method and it relies on
flush_eventsbeing properly implemented.Interactive backends should implement this in a more native way.
- statusTip(self) str
- stop_event_loop(event=None)
Stop the current blocking event loop.
Interactive backends need to reimplement this to match
start_event_loop
- style(self) QStyle | None
- styleSheet(self) str
- switch_backends(FigureCanvasClass)
[Deprecated] Instantiate an instance of FigureCanvasClass
This is used for backend switching, e.g., to instantiate a FigureCanvasPS from a FigureCanvasGTK. Note, deep copying is not done, so any changes to one of the instances (e.g., setting figure size or line props), will be reflected in the other
Notes
Deprecated since version 3.8.
- tabletEvent(self, a0: QTabletEvent | None)
- testAttribute(self, attribute: Qt.WidgetAttribute) bool
- thread(self) QThread | None
- timerEvent(self, a0: QTimerEvent | None)
- toolTip(self) str
- toolTipDuration(self) int
- tostring_argb()
Get the image as ARGB bytes.
drawmust be called at least once before this function will work and to update the renderer for any subsequent changes to the Figure.
- tostring_rgb()
[Deprecated] Get the image as RGB bytes.
drawmust be called at least once before this function will work and to update the renderer for any subsequent changes to the Figure.Notes
Deprecated since version 3.8: Use buffer_rgba instead.
- tr(self, sourceText: str | None, disambiguation: str | None = None, n: int = -1) str
- underMouse(self) bool
- ungrabGesture(self, type: Qt.GestureType)
- unsetCursor(self)
- unsetLayoutDirection(self)
- unsetLocale(self)
- update(self)
- update(self, a0: QRect) None
- update(self, a0: QRegion) None
- update(self, ax: int, ay: int, aw: int, ah: int) None
- updateGeometry(self)
- updateMicroFocus(self)
- updatesEnabled(self) bool
- property value
Get the current value of the scope.
- visibleRegion(self) QRegion
- whatsThis(self) str
- wheelEvent(self, a0: QWheelEvent | None)
- width(self) int
- widthMM(self) int
- winId(self) PyQt5.sip.voidptr
- window(self) QWidget | None
- windowFilePath(self) str
- windowFlags(self) Qt.WindowFlags
- windowHandle(self) QWindow | None
- windowIcon(self) QIcon
- windowIconChanged
QIcon) [signal]
- Type:
windowIconChanged(self, icon
- windowIconText(self) str
- windowIconTextChanged
Optional[str]) [signal]
- Type:
windowIconTextChanged(self, iconText
- windowModality(self) Qt.WindowModality
- windowOpacity(self) float
- windowRole(self) str
- windowState(self) Qt.WindowStates
- windowTitle(self) str
- windowTitleChanged
Optional[str]) [signal]
- Type:
windowTitleChanged(self, title
- windowType(self) Qt.WindowType
- x(self) int
- y(self) int