PlotCanvas¶
- class PlotCanvas(design: QDesign, parent: QMainWindowPlot = None, logger=None, statusbar_label=None)¶
Main Plot canvas widget.
This class extends the FigureCanvas class.
- Access with:
canvas = gui.canvas
- Parameters:
design (QDesign) – The design.
parent (QMainWindowPlot) – The main window. Defaults to None.
logger (logger) – The logger. Defaults to None.
statusbar_label (str) – Statusbar label. Defaults to None.
Attributes
- DrawChildren = PySide2.QtWidgets.QWidget.RenderFlag.DrawChildren¶
- DrawWindowBackground = PySide2.QtWidgets.QWidget.RenderFlag.DrawWindowBackground¶
- IgnoreMask = PySide2.QtWidgets.QWidget.RenderFlag.IgnoreMask¶
- PdmDepth = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmDepth¶
- PdmDevicePixelRatio = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmDevicePixelRatio¶
- PdmDevicePixelRatioScaled = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmDevicePixelRatioScaled¶
- PdmDpiX = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmDpiX¶
- PdmDpiY = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmDpiY¶
- PdmHeight = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmHeight¶
- PdmHeightMM = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmHeightMM¶
- PdmNumColors = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmNumColors¶
- PdmPhysicalDpiX = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmPhysicalDpiX¶
- PdmPhysicalDpiY = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmPhysicalDpiY¶
- PdmWidth = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmWidth¶
- PdmWidthMM = PySide2.QtGui.QPaintDevice.PaintDeviceMetric.PdmWidthMM¶
- button_pick_id¶
- buttond = {PySide2.QtCore.Qt.MouseButton.LeftButton: MouseButton.LEFT, PySide2.QtCore.Qt.MouseButton.RightButton: MouseButton.RIGHT, PySide2.QtCore.Qt.MouseButton.MiddleButton: MouseButton.MIDDLE, PySide2.QtCore.Qt.MouseButton.XButton1: MouseButton.BACK, PySide2.QtCore.Qt.MouseButton.XButton2: MouseButton.FORWARD}¶
- callbacks¶
- customContextMenuRequested¶
- destroyed¶
- 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.
- events = ['resize_event', 'draw_event', 'key_press_event', 'key_release_event', 'button_press_event', 'button_release_event', 'scroll_event', 'motion_notify_event', 'pick_event', 'figure_enter_event', 'figure_leave_event', 'axes_enter_event', 'axes_leave_event', 'close_event']¶
- filetypes = {'eps': 'Encapsulated Postscript', 'jpeg': 'Joint Photographic Experts Group', 'jpg': 'Joint Photographic Experts Group', 'pdf': 'Portable Document Format', 'pgf': 'PGF code for LaTeX', 'png': 'Portable Network Graphics', 'ps': 'Postscript', 'raw': 'Raw RGBA bitmap', 'rgba': 'Raw RGBA bitmap', 'svg': 'Scalable Vector Graphics', 'svgz': 'Scalable Vector Graphics', 'tif': 'Tagged Image File Format', 'tiff': 'Tagged Image File Format', 'webp': 'WebP Image Format'}¶
- fixed_dpi = None¶
- objectNameChanged¶
- painters¶
- required_interactive_framework = 'qt'¶
- scroll_pick_id¶
- staticMetaObject = <PySide2.QtCore.QMetaObject object>¶
- supports_blit = True¶
- windowIconChanged¶
- windowIconTextChanged¶
- windowTitleChanged¶
Methods
- acceptDrops(self) bool ¶
- accessibleDescription(self) str ¶
- accessibleName(self) str ¶
- actionEvent(self, event: PySide2.QtGui.QActionEvent) None ¶
- actions(self) List[PySide2.QtWidgets.QAction] ¶
- activateWindow(self) None ¶
- addAction(self, action: PySide2.QtWidgets.QAction) None ¶
- addActions(self, actions: Sequence[PySide2.QtWidgets.QAction]) None ¶
- adjustSize(self) None ¶
- autoFillBackground(self) bool ¶
- auto_scale()¶
Automaticlaly scale.
- backgroundRole(self) PySide2.QtGui.QPalette.ColorRole ¶
- backingStore(self) PySide2.QtGui.QBackingStore ¶
- baseSize(self) PySide2.QtCore.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.
draw must be called at least once before this function will work and to update the renderer for any subsequent changes to the Figure.
- button_press_event(x, y, button, dblclick=False, guiEvent=None)¶
[Deprecated] Callback processing for mouse button press events.
Backend derived classes should call this function on any mouse button press. (x, y) are the canvas coords ((0, 0) is lower left). button and key are as defined in MouseEvent.
This method will call all functions connected to the ‘button_press_event’ with a MouseEvent instance.
Notes
Deprecated since version 3.6: Use callbacks.process(‘button_press_event’, MouseEvent(…)) instead.
- button_release_event(x, y, button, guiEvent=None)¶
[Deprecated] Callback processing for mouse button release events.
Backend derived classes should call this function on any mouse button release.
This method will call all functions connected to the ‘button_release_event’ with a MouseEvent instance.
- Parameters:
x (float) – The canvas coordinates where 0=left.
y (float) – The canvas coordinates where 0=bottom.
guiEvent – The native UI event that generated the Matplotlib event.
Notes
Deprecated since version 3.6: Use callbacks.process(‘button_release_event’, MouseEvent(…)) instead.
- changeEvent(self, event: PySide2.QtCore.QEvent) None ¶
- childAt(self, p: PySide2.QtCore.QPoint) PySide2.QtWidgets.QWidget ¶
- childAt(self, x: int, y: int) PySide2.QtWidgets.QWidget
- childEvent(self, event: PySide2.QtCore.QChildEvent) None ¶
- children(self) List[PySide2.QtCore.QObject] ¶
- childrenRect(self) PySide2.QtCore.QRect ¶
- childrenRegion(self) PySide2.QtGui.QRegion ¶
- clearFocus(self) None ¶
- clearMask(self) None ¶
- clear_annotation()¶
Clear the annotations.
- Raises:
Exception – Error while clearing the annotations
- clear_axis(ax: Axes | None = None)¶
Clear an axis or clear all axes.
- Parameters:
ax (plt.Axes) – Clear an axis, or if None, then clear all axes. Defaults to None.
- close(self) bool ¶
- closeEvent(self, event: PySide2.QtGui.QCloseEvent) None ¶
- close_event(guiEvent=None)¶
[Deprecated] Pass a CloseEvent to all functions connected to
close_event
.Notes
Deprecated since version 3.6: Use callbacks.process(‘close_event’, CloseEvent(…)) instead.
- colorCount(self) int ¶
- static connect(arg__1: PySide2.QtCore.QObject, arg__2: bytes, arg__3: Callable, type: PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) bool ¶
- static connect(self, arg__1: bytes, arg__2: Callable, type: PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) bool
- static connect(self, arg__1: bytes, arg__2: PySide2.QtCore.QObject, arg__3: bytes, type: PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) bool
- static connect(self, sender: PySide2.QtCore.QObject, signal: bytes, member: bytes, type: PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QMetaObject.Connection
- static connect(sender: PySide2.QtCore.QObject, signal: PySide2.QtCore.QMetaMethod, receiver: PySide2.QtCore.QObject, method: PySide2.QtCore.QMetaMethod, type: PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QMetaObject.Connection
- static connect(sender: PySide2.QtCore.QObject, signal: bytes, receiver: PySide2.QtCore.QObject, member: bytes, type: PySide2.QtCore.Qt.ConnectionType = PySide2.QtCore.Qt.ConnectionType.AutoConnection) PySide2.QtCore.QMetaObject.Connection
- connectNotify(self, signal: PySide2.QtCore.QMetaMethod) None ¶
- contentsMargins(self) PySide2.QtCore.QMargins ¶
- contentsRect(self) PySide2.QtCore.QRect ¶
- contextMenuEvent(self, event: PySide2.QtGui.QContextMenuEvent) None ¶
- contextMenuPolicy(self) PySide2.QtCore.Qt.ContextMenuPolicy ¶
- copy_from_bbox(bbox)¶
- create(self, arg__1: int = 0, initializeWindow: bool = True, destroyOldWindow: bool = True) None ¶
- createWinId(self) None ¶
- static createWindowContainer(window: PySide2.QtGui.QWindow, parent: Optional[PySide2.QtWidgets.QWidget] = None, flags: PySide2.QtCore.Qt.WindowFlags = Default(Qt.WindowFlags)) PySide2.QtWidgets.QWidget ¶
- cursor(self) PySide2.QtGui.QCursor ¶
- customEvent(self, event: PySide2.QtCore.QEvent) None ¶
- deleteLater(self) None ¶
- depth(self) int ¶
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True) None ¶
- devType(self) int ¶
- devicePixelRatio(self) int ¶
- devicePixelRatioF(self) float ¶
- static devicePixelRatioFScale() float ¶
- static disconnect(arg__1: PySide2.QtCore.QMetaObject.Connection) bool ¶
- static disconnect(arg__1: PySide2.QtCore.QObject, arg__2: bytes, arg__3: Callable) bool
- static disconnect(self, arg__1: bytes, arg__2: Callable) bool
- static disconnect(self, receiver: PySide2.QtCore.QObject, member: Optional[bytes] = None) bool
- static disconnect(self, signal: bytes, receiver: PySide2.QtCore.QObject, member: bytes) bool
- static disconnect(sender: PySide2.QtCore.QObject, signal: PySide2.QtCore.QMetaMethod, receiver: PySide2.QtCore.QObject, member: PySide2.QtCore.QMetaMethod) bool
- static disconnect(sender: PySide2.QtCore.QObject, signal: bytes, receiver: PySide2.QtCore.QObject, member: bytes) bool
- disconnectNotify(self, signal: PySide2.QtCore.QMetaMethod) None ¶
- dragEnterEvent(self, event: PySide2.QtGui.QDragEnterEvent) None ¶
- dragLeaveEvent(self, event: PySide2.QtGui.QDragLeaveEvent) None ¶
- dragMoveEvent(self, event: PySide2.QtGui.QDragMoveEvent) None ¶
- draw()¶
Render the figure, and queue a request for a Qt draw.
- drawRectangle(rect)¶
- draw_event(renderer)¶
[Deprecated] Pass a DrawEvent to all functions connected to
draw_event
.Notes
Deprecated since version 3.6: Use callbacks.process(‘draw_event’, DrawEvent(…)) instead.
- draw_idle()¶
Queue redraw of the Agg buffer and request Qt paintEvent.
- dropEvent(self, event: PySide2.QtGui.QDropEvent) None ¶
- dumpObjectInfo(self) None ¶
- dumpObjectTree(self) None ¶
- dynamicPropertyNames(self) List[PySide2.QtCore.QByteArray] ¶
- effectiveWinId(self) int ¶
- emit(self, arg__1: bytes, *args: None) bool ¶
- ensurePolished(self) None ¶
- enterEvent(self, event: PySide2.QtCore.QEvent) None ¶
- enter_notify_event(guiEvent=None, *, xy)¶
[Deprecated] Callback processing for the mouse cursor entering the canvas.
Backend derived classes should call this function when entering canvas.
- Parameters:
guiEvent – The native UI event that generated the Matplotlib event.
xy ((float, float)) – The coordinate location of the pointer when the canvas is entered.
Notes
Deprecated since version 3.6: Use callbacks.process(‘enter_notify_event’, LocationEvent(…)) instead.
- event(self, event: PySide2.QtCore.QEvent) bool ¶
- eventFilter(self, watched: PySide2.QtCore.QObject, event: PySide2.QtCore.QEvent) bool ¶
- static find(arg__1: int) PySide2.QtWidgets.QWidget ¶
- findChild(self, arg__1: type, arg__2: str = '') object ¶
- findChildren(self, arg__1: type, arg__2: PySide2.QtCore.QRegExp) Iterable ¶
- findChildren(self, arg__1: type, arg__2: PySide2.QtCore.QRegularExpression) Iterable
- findChildren(self, arg__1: type, arg__2: str = '') Iterable
- find_component_bounds(components: List[str], zoom: float = 1.2)¶
Find bounds of a set of components.
- Parameters:
components (List[str]) – A list of component names
zoom (float) – Fraction to expand the bounding vbox by
- Returns:
List of x,y coordinates defining the bounding box
- Return type:
List
- flush_events()¶
Flush the GUI events for the figure.
Interactive backends need to reimplement this method.
- focusInEvent(self, event: PySide2.QtGui.QFocusEvent) None ¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, next: bool) bool ¶
- focusOutEvent(self, event: PySide2.QtGui.QFocusEvent) None ¶
- focusPolicy(self) PySide2.QtCore.Qt.FocusPolicy ¶
- focusPreviousChild(self) bool ¶
- focusProxy(self) PySide2.QtWidgets.QWidget ¶
- focusWidget(self) PySide2.QtWidgets.QWidget ¶
- font(self) PySide2.QtGui.QFont ¶
- fontInfo(self) PySide2.QtGui.QFontInfo ¶
- fontMetrics(self) PySide2.QtGui.QFontMetrics ¶
- foregroundRole(self) PySide2.QtGui.QPalette.ColorRole ¶
- frameGeometry(self) PySide2.QtCore.QRect ¶
- frameSize(self) PySide2.QtCore.QSize ¶
- geometry(self) PySide2.QtCore.QRect ¶
- getContentsMargins(self) Tuple[int, int, int, int] ¶
- get_axis()¶
Gets the current axis.
- 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.
- get_renderer(cleared=<deprecated parameter>)¶
- 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: PySide2.QtCore.QRect = PySide2.QtCore.QRect(0, 0, -1, -1)) PySide2.QtGui.QPixmap ¶
- grabGesture(self, type: PySide2.QtCore.Qt.GestureType, flags: PySide2.QtCore.Qt.GestureFlags = Default(Qt.GestureFlags)) None ¶
- grabKeyboard(self) None ¶
- grabMouse(self) None ¶
- grabMouse(self, arg__1: PySide2.QtGui.QCursor) None
- grabShortcut(self, key: PySide2.QtGui.QKeySequence, context: PySide2.QtCore.Qt.ShortcutContext = PySide2.QtCore.Qt.ShortcutContext.WindowShortcut) int ¶
- grab_mouse(ax)¶
Set the child ~.axes.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) PySide2.QtWidgets.QGraphicsEffect ¶
- graphicsProxyWidget(self) PySide2.QtWidgets.QGraphicsProxyWidget ¶
- hasFocus(self) bool ¶
- hasHeightForWidth(self) bool ¶
- hasMouseTracking(self) bool ¶
- hasTabletTracking(self) bool ¶
- height(self) int ¶
- heightForWidth(self, arg__1: int) int ¶
- heightMM(self) int ¶
- hide(self) None ¶
- hideEvent(self, event: PySide2.QtGui.QHideEvent) None ¶
- highlight_components(component_names: List[str])¶
Highlight a list of components.
- Parameters:
component_names (List[str]) – A list of component names
- inaxes(xy)¶
Return the topmost visible ~.axes.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:
~matplotlib.axes.Axes or None
- inherits(self, classname: bytes) bool ¶
- initPainter(self, painter: PySide2.QtGui.QPainter) None ¶
- inputMethodEvent(self, event: PySide2.QtGui.QInputMethodEvent) None ¶
- inputMethodHints(self) PySide2.QtCore.Qt.InputMethodHints ¶
- inputMethodQuery(self, arg__1: PySide2.QtCore.Qt.InputMethodQuery) Any ¶
- insertAction(self, before: PySide2.QtWidgets.QAction, action: PySide2.QtWidgets.QAction) None ¶
- insertActions(self, before: PySide2.QtWidgets.QAction, actions: Sequence[PySide2.QtWidgets.QAction]) None ¶
- installEventFilter(self, filterObj: PySide2.QtCore.QObject) None ¶
- internalWinId(self) int ¶
- isActiveWindow(self) bool ¶
- isAncestorOf(self, child: PySide2.QtWidgets.QWidget) bool ¶
- isEnabled(self) bool ¶
- isEnabledTo(self, arg__1: PySide2.QtWidgets.QWidget) bool ¶
- isEnabledToTLW(self) 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: PySide2.QtCore.QMetaMethod) bool ¶
- isTopLevel(self) bool ¶
- isVisible(self) bool ¶
- isVisibleTo(self, arg__1: PySide2.QtWidgets.QWidget) 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, event: PySide2.QtGui.QKeyEvent) None ¶
- keyReleaseEvent(self, event: PySide2.QtGui.QKeyEvent) None ¶
- key_press_event(key, guiEvent=None)¶
[Deprecated] Pass a KeyEvent to all functions connected to
key_press_event
.Notes
Deprecated since version 3.6: Use callbacks.process(‘key_press_event’, KeyEvent(…)) instead.
- key_release_event(key, guiEvent=None)¶
[Deprecated] Pass a KeyEvent to all functions connected to
key_release_event
.Notes
Deprecated since version 3.6: Use callbacks.process(‘key_release_event’, KeyEvent(…)) instead.
- static keyboardGrabber() PySide2.QtWidgets.QWidget ¶
- killTimer(self, id: int) None ¶
- layout(self) PySide2.QtWidgets.QLayout ¶
- layoutDirection(self) PySide2.QtCore.Qt.LayoutDirection ¶
- leaveEvent(self, event: PySide2.QtCore.QEvent) None ¶
- leave_notify_event(guiEvent=None)¶
[Deprecated] Callback processing for the mouse cursor leaving the canvas.
Backend derived classes should call this function when leaving canvas.
- Parameters:
guiEvent – The native UI event that generated the Matplotlib event.
Notes
Deprecated since version 3.6: Use callbacks.process(‘leave_notify_event’, LocationEvent(…)) instead.
- locale(self) PySide2.QtCore.QLocale ¶
- logicalDpiX(self) int ¶
- logicalDpiY(self) int ¶
- lower(self) None ¶
- mapFrom(self, arg__1: PySide2.QtWidgets.QWidget, arg__2: PySide2.QtCore.QPoint) PySide2.QtCore.QPoint ¶
- mapFromGlobal(self, arg__1: PySide2.QtCore.QPoint) PySide2.QtCore.QPoint ¶
- mapFromParent(self, arg__1: PySide2.QtCore.QPoint) PySide2.QtCore.QPoint ¶
- mapTo(self, arg__1: PySide2.QtWidgets.QWidget, arg__2: PySide2.QtCore.QPoint) PySide2.QtCore.QPoint ¶
- mapToGlobal(self, arg__1: PySide2.QtCore.QPoint) PySide2.QtCore.QPoint ¶
- mapToParent(self, arg__1: PySide2.QtCore.QPoint) PySide2.QtCore.QPoint ¶
- mask(self) PySide2.QtGui.QRegion ¶
- maximumHeight(self) int ¶
- maximumSize(self) PySide2.QtCore.QSize ¶
- maximumWidth(self) int ¶
- metaObject(self) PySide2.QtCore.QMetaObject ¶
- metric(self, arg__1: PySide2.QtGui.QPaintDevice.PaintDeviceMetric) int ¶
- minimumHeight(self) int ¶
- minimumSize(self) PySide2.QtCore.QSize ¶
- minimumSizeHint(self) PySide2.QtCore.QSize ¶
- minimumWidth(self) int ¶
- minumumSizeHint()¶
- motion_notify_event(x, y, guiEvent=None)¶
[Deprecated] Callback processing for mouse movement events.
Backend derived classes should call this function on any motion-notify-event.
This method will call all functions connected to the ‘motion_notify_event’ with a MouseEvent instance.
- Parameters:
x (float) – The canvas coordinates where 0=left.
y (float) – The canvas coordinates where 0=bottom.
guiEvent – The native UI event that generated the Matplotlib event.
Notes
Deprecated since version 3.6: Use callbacks.process(‘motion_notify_event’, MouseEvent(…)) instead.
- mouseDoubleClickEvent(self, event: PySide2.QtGui.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.
- static mouseGrabber() PySide2.QtWidgets.QWidget ¶
- mouseMoveEvent(self, event: PySide2.QtGui.QMouseEvent) None ¶
- mousePressEvent(self, event: PySide2.QtGui.QMouseEvent) None ¶
- mouseReleaseEvent(self, event: PySide2.QtGui.QMouseEvent) None ¶
- move(self, arg__1: PySide2.QtCore.QPoint) None ¶
- move(self, x: int, y: int) None
- moveEvent(self, event: PySide2.QtGui.QMoveEvent) None ¶
- moveToThread(self, thread: PySide2.QtCore.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
inaxes
attribute of the event will be set to the ~matplotlib.axes.Axes the event occurs is over, and additionally, the variablesxdata
andydata
attributes 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: PySide2.QtCore.QByteArray, message: int) Tuple[bool, int] ¶
- nativeParentWidget(self) PySide2.QtWidgets.QWidget ¶
- 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
False
or0
will be removed from the timer.
Examples
>>> timer = fig.canvas.new_timer(callbacks=[(f1, (1,), {'a': 3})])
- nextInFocusChain(self) PySide2.QtWidgets.QWidget ¶
- normalGeometry(self) PySide2.QtCore.QRect ¶
- objectName(self) str ¶
- overrideWindowFlags(self, type: PySide2.QtCore.Qt.WindowFlags) None ¶
- overrideWindowState(self, state: PySide2.QtCore.Qt.WindowStates) None ¶
- paintEngine(self) PySide2.QtGui.QPaintEngine ¶
- 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) PySide2.QtGui.QPalette ¶
- parent(self) PySide2.QtCore.QObject ¶
- parentWidget(self) PySide2.QtWidgets.QWidget ¶
- physicalDpiX(self) int ¶
- physicalDpiY(self) int ¶
- pick(mouseevent)¶
[Deprecated]
Notes
Deprecated since version 3.6: Use canvas.figure.pick instead.
- pick_event(mouseevent, artist, **kwargs)¶
[Deprecated] Callback processing for pick events.
This method will be called by artists who are picked and will fire off PickEvent callbacks registered listeners.
Note that artists are not pickable by default (see .Artist.set_picker).
Notes
Deprecated since version 3.6: Use callbacks.process(‘pick_event’, PickEvent(…)) instead.
- plot(clear=True, with_try=True)¶
Render the plot.
- Parameters:
clear (bool) – True to clear everything first. Defaults to True.
with_try (bool) – True to execute in a try-catch block. Defaults to True.
- Raises:
Exception – Plotting error
- pos(self) PySide2.QtCore.QPoint ¶
- previousInFocusChain(self) PySide2.QtWidgets.QWidget ¶
- 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 (color or ‘auto’, default: :rc:`savefig.facecolor`) – The facecolor of the figure. If ‘auto’, use the current figure facecolor.
edgecolor (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, default: :rc:`savefig.pad_inches`) – Amount of padding around the figure when bbox_inches is ‘tight’.
bbox_extra_artists (list of ~matplotlib.artist.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, *, 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.save when saving the figure.
- print_jpg(filename_or_obj, *, 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.save when 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_raw(filename_or_obj)¶
- print_rgba(filename_or_obj)¶
- print_tif(filename_or_obj, *, 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.save when saving the figure.
- print_tiff(filename_or_obj, *, 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.save when saving the figure.
- print_to_buffer()¶
- print_webp(filename_or_obj, *, 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.save when saving the figure.
- property(self, name: bytes) Any ¶
- raise_(self) None ¶
- receivers(self, signal: bytes) int ¶
- rect(self) PySide2.QtCore.QRect ¶
- redirected(self, offset: PySide2.QtCore.QPoint) PySide2.QtGui.QPaintDevice ¶
- refresh()¶
Force refresh.
Does not replot renderer. Just mpl refresh.
- static registerUserData() int ¶
- releaseKeyboard(self) None ¶
- releaseMouse(self) None ¶
- releaseShortcut(self, id: int) None ¶
- release_mouse(ax)¶
Release the mouse grab held by the ~.axes.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: PySide2.QtWidgets.QAction) None ¶
- removeEventFilter(self, obj: PySide2.QtCore.QObject) None ¶
- render(self, painter: PySide2.QtGui.QPainter, targetOffset: PySide2.QtCore.QPoint, sourceRegion: PySide2.QtGui.QRegion = Default(QRegion), renderFlags: PySide2.QtWidgets.QWidget.RenderFlags = Instance(QWidget.RenderFlags(QWidget.DrawWindowBackground | QWidget.DrawChildren))) None ¶
- render(self, target: PySide2.QtGui.QPaintDevice, targetOffset: PySide2.QtCore.QPoint = Default(QPoint), sourceRegion: PySide2.QtGui.QRegion = Default(QRegion), renderFlags: PySide2.QtWidgets.QWidget.RenderFlags = Instance(QWidget.RenderFlags(QWidget.DrawWindowBackground | QWidget.DrawChildren))) None
- repaint(self) None ¶
- repaint(self, arg__1: PySide2.QtCore.QRect) None
- repaint(self, arg__1: PySide2.QtGui.QRegion) None
- repaint(self, x: int, y: int, w: int, h: int) None
- resize(w, h)¶
UNUSED: Set the canvas size in pixels.
Certain backends may implement a similar method internally, but this is not a requirement of, nor is it used by, Matplotlib itself.
- resizeEvent(self, event: PySide2.QtGui.QResizeEvent) None ¶
- resize_event()¶
[Deprecated] Pass a ResizeEvent to all functions connected to
resize_event
.Notes
Deprecated since version 3.6: Use callbacks.process(‘resize_event’, ResizeEvent(…)) instead.
- restoreGeometry(self, geometry: PySide2.QtCore.QByteArray) bool ¶
- restore_region(region, bbox=None, xy=None)¶
- saveGeometry(self) PySide2.QtCore.QByteArray ¶
- screen(self) PySide2.QtGui.QScreen ¶
- scroll(self, dx: int, dy: int) None ¶
- scroll(self, dx: int, dy: int, arg__3: PySide2.QtCore.QRect) None
- scroll_event(x, y, step, guiEvent=None)¶
[Deprecated] Callback processing for scroll events.
Backend derived classes should call this function on any scroll wheel event. (x, y) are the canvas coords ((0, 0) is lower left). button and key are as defined in MouseEvent.
This method will call all functions connected to the ‘scroll_event’ with a MouseEvent instance.
Notes
Deprecated since version 3.6: Use callbacks.process(‘scroll_event’, MouseEvent(…)) instead.
- sender(self) PySide2.QtCore.QObject ¶
- senderSignalIndex(self) int ¶
- setAcceptDrops(self, on: bool) None ¶
- setAccessibleDescription(self, description: str) None ¶
- setAccessibleName(self, name: str) None ¶
- setAttribute(self, arg__1: PySide2.QtCore.Qt.WidgetAttribute, on: bool = True) None ¶
- setAutoFillBackground(self, enabled: bool) None ¶
- setBackgroundRole(self, arg__1: PySide2.QtGui.QPalette.ColorRole) None ¶
- setBaseSize(self, arg__1: PySide2.QtCore.QSize) None ¶
- setBaseSize(self, basew: int, baseh: int) None
- setContentsMargins(self, left: int, top: int, right: int, bottom: int) None ¶
- setContentsMargins(self, margins: PySide2.QtCore.QMargins) None
- setContextMenuPolicy(self, policy: PySide2.QtCore.Qt.ContextMenuPolicy) None ¶
- setCursor(self, arg__1: PySide2.QtGui.QCursor) None ¶
- setDisabled(self, arg__1: bool) None ¶
- setEnabled(self, arg__1: bool) None ¶
- setFixedHeight(self, h: int) None ¶
- setFixedSize(self, arg__1: PySide2.QtCore.QSize) None ¶
- setFixedSize(self, w: int, h: int) None
- setFixedWidth(self, w: int) None ¶
- setFocus(self) None ¶
- setFocus(self, reason: PySide2.QtCore.Qt.FocusReason) None
- setFocusPolicy(self, policy: PySide2.QtCore.Qt.FocusPolicy) None ¶
- setFocusProxy(self, arg__1: PySide2.QtWidgets.QWidget) None ¶
- setFont(self, arg__1: PySide2.QtGui.QFont) None ¶
- setForegroundRole(self, arg__1: PySide2.QtGui.QPalette.ColorRole) None ¶
- setGeometry(self, arg__1: PySide2.QtCore.QRect) None ¶
- setGeometry(self, x: int, y: int, w: int, h: int) None
- setGraphicsEffect(self, effect: PySide2.QtWidgets.QGraphicsEffect) None ¶
- setHidden(self, hidden: bool) None ¶
- setInputMethodHints(self, hints: PySide2.QtCore.Qt.InputMethodHints) None ¶
- setLayout(self, arg__1: PySide2.QtWidgets.QLayout) None ¶
- setLayoutDirection(self, direction: PySide2.QtCore.Qt.LayoutDirection) None ¶
- setLocale(self, locale: PySide2.QtCore.QLocale) None ¶
- setMask(self, arg__1: PySide2.QtGui.QBitmap) None ¶
- setMask(self, arg__1: PySide2.QtGui.QRegion) None
- setMaximumHeight(self, maxh: int) None ¶
- setMaximumSize(self, arg__1: PySide2.QtCore.QSize) None ¶
- setMaximumSize(self, maxw: int, maxh: int) None
- setMaximumWidth(self, maxw: int) None ¶
- setMinimumHeight(self, minh: int) None ¶
- setMinimumSize(self, arg__1: PySide2.QtCore.QSize) None ¶
- setMinimumSize(self, minw: int, minh: int) None
- setMinimumWidth(self, minw: int) None ¶
- setMouseTracking(self, enable: bool) None ¶
- setObjectName(self, name: str) None ¶
- setPalette(self, arg__1: PySide2.QtGui.QPalette) None ¶
- setParent(self, parent: PySide2.QtCore.QObject) None ¶
- setParent(self, parent: PySide2.QtWidgets.QWidget) None
- setParent(self, parent: PySide2.QtWidgets.QWidget, f: PySide2.QtCore.Qt.WindowFlags) None
- setProperty(self, name: bytes, value: Any) bool ¶
- setShortcutAutoRepeat(self, id: int, enable: bool = True) None ¶
- setShortcutEnabled(self, id: int, enable: bool = True) None ¶
- setSizeIncrement(self, arg__1: PySide2.QtCore.QSize) None ¶
- setSizeIncrement(self, w: int, h: int) None
- setSizePolicy(self, arg__1: PySide2.QtWidgets.QSizePolicy) None ¶
- setSizePolicy(self, horizontal: PySide2.QtWidgets.QSizePolicy.Policy, vertical: PySide2.QtWidgets.QSizePolicy.Policy) None
- setStatusTip(self, arg__1: str) None ¶
- setStyle(self, arg__1: PySide2.QtWidgets.QStyle) None ¶
- setStyleSheet(self, styleSheet: str) None ¶
- static setTabOrder(arg__1: PySide2.QtWidgets.QWidget, arg__2: PySide2.QtWidgets.QWidget) None ¶
- setTabletTracking(self, enable: bool) None ¶
- setToolTip(self, arg__1: str) None ¶
- setToolTipDuration(self, msec: int) None ¶
- setUpdatesEnabled(self, enable: bool) None ¶
- setVisible(self, visible: bool) None ¶
- setWhatsThis(self, arg__1: str) None ¶
- setWindowFilePath(self, filePath: str) None ¶
- setWindowFlag(self, arg__1: PySide2.QtCore.Qt.WindowType, on: bool = True) None ¶
- setWindowFlags(self, type: PySide2.QtCore.Qt.WindowFlags) None ¶
- setWindowIcon(self, icon: PySide2.QtGui.QIcon) None ¶
- setWindowIconText(self, arg__1: str) None ¶
- setWindowModality(self, windowModality: PySide2.QtCore.Qt.WindowModality) None ¶
- setWindowModified(self, arg__1: bool) None ¶
- setWindowOpacity(self, level: float) None ¶
- setWindowRole(self, arg__1: str) None ¶
- setWindowState(self, state: PySide2.QtCore.Qt.WindowStates) None ¶
- setWindowTitle(self, arg__1: str) None ¶
- set_component(name: str)¶
Shortcut to set a component in the component widget to be examined.
- Parameters:
name (str) – Name of the component in the design
- 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.
- setup_figure_and_axes()¶
Main setup from scratch.
- setup_rendering()¶
Line segment simplificatio: For plots that have line segments (e.g. typical line plots, outlines of polygons, etc.), rendering performance can be controlled by the path.simplify and path.simplify_threshold.
- path_simplify:
When True, simplify paths by removing “invisible” points to reduce file size and increase rendering speed
- path_simplify_threshold:
The threshold of similarity below which vertices will be removed in the simplification process
- chuncksize:
0 to disable; values in the range 10000 to 100000 can improve speed slightly and prevent an Agg rendering failure when plotting very large data sets, especially if they are very gappy. It may cause minor artifacts, though. A value of 20000 is probably a good starting point.
https://matplotlib.org/3.1.1/tutorials/introductory/usage.html
- show(self) None ¶
- showEvent(self, event: PySide2.QtGui.QShowEvent) None ¶
- showFullScreen(self) None ¶
- showMaximized(self) None ¶
- showMinimized(self) None ¶
- showNormal(self) None ¶
- signalsBlocked(self) bool ¶
- size(self) PySide2.QtCore.QSize ¶
- sizeHint(self) PySide2.QtCore.QSize ¶
- sizeIncrement(self) PySide2.QtCore.QSize ¶
- sizePolicy(self) PySide2.QtWidgets.QSizePolicy ¶
- stackUnder(self, arg__1: PySide2.QtWidgets.QWidget) None ¶
- startTimer(self, interval: int, timerType: PySide2.QtCore.Qt.TimerType = PySide2.QtCore.Qt.TimerType.CoarseTimer) int ¶
- start_event_loop(timeout=0)¶
Start a blocking event loop.
Such an event loop is used by interactive functions, such as ~.Figure.ginput and ~.Figure.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_events being 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) PySide2.QtWidgets.QStyle ¶
- styleSheet(self) str ¶
- style_axis(ax, num: int)¶
Style the axis.
- Parameters:
ax (axis) – The axis
num (int) – Not used
- style_figure()¶
Style a figure.
- switch_backends(FigureCanvasClass)¶
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
- tabletEvent(self, event: PySide2.QtGui.QTabletEvent) None ¶
- testAttribute(self, arg__1: PySide2.QtCore.Qt.WidgetAttribute) bool ¶
- thread(self) PySide2.QtCore.QThread ¶
- timerEvent(self, event: PySide2.QtCore.QTimerEvent) None ¶
- toolTip(self) str ¶
- toolTipDuration(self) int ¶
- topLevelWidget(self) PySide2.QtWidgets.QWidget ¶
- tostring_argb()¶
Get the image as ARGB bytes.
draw must be called at least once before this function will work and to update the renderer for any subsequent changes to the Figure.
- tostring_rgb()¶
Get the image as RGB bytes.
draw must be called at least once before this function will work and to update the renderer for any subsequent changes to the Figure.
- tr(self, arg__1: bytes, arg__2: bytes = b'', arg__3: int = -1) str ¶
- underMouse(self) bool ¶
- ungrabGesture(self, type: PySide2.QtCore.Qt.GestureType) None ¶
- unsetCursor(self) None ¶
- unsetLayoutDirection(self) None ¶
- unsetLocale(self) None ¶
- update(self) None ¶
- update(self, arg__1: PySide2.QtCore.QRect) None
- update(self, arg__1: PySide2.QtGui.QRegion) None
- update(self, x: int, y: int, w: int, h: int) None
- updateGeometry(self) None ¶
- updateMicroFocus(self) None ¶
- updatesEnabled(self) bool ¶
- visibleRegion(self) PySide2.QtGui.QRegion ¶
- welcome_message()¶
The GUI displays a message to let users know they are using Qiskit Metal.
- whatsThis(self) str ¶
- wheelEvent(self, event: PySide2.QtGui.QWheelEvent) None ¶
- width(self) int ¶
- widthMM(self) int ¶
- winId(self) int ¶
- window(self) PySide2.QtWidgets.QWidget ¶
- windowFilePath(self) str ¶
- windowFlags(self) PySide2.QtCore.Qt.WindowFlags ¶
- windowHandle(self) PySide2.QtGui.QWindow ¶
- windowIcon(self) PySide2.QtGui.QIcon ¶
- windowIconText(self) str ¶
- windowModality(self) PySide2.QtCore.Qt.WindowModality ¶
- windowOpacity(self) float ¶
- windowRole(self) str ¶
- windowState(self) PySide2.QtCore.Qt.WindowStates ¶
- windowTitle(self) str ¶
- windowType(self) PySide2.QtCore.Qt.WindowType ¶
- x(self) int ¶
- y(self) int ¶
- zoom_to_rectangle(bounds: tuple, ax: Axes | None = None)¶
Zoom to the specified rectangle.
- Parameters:
bounds (tuple) – Tuple containing minx, miny, maxx, maxy values for the bounds of the series as a whole.
ax (Axes) – Does for all if none (default: {None})