Class: QgsPlotCanvas¶
Plot canvas is a class for displaying interactive 2d charts and plots.
Added in version 3.26.
Class Hierarchy¶
Base classes¶
Subclasses¶
A canvas for elevation profiles. |
Methods
Sets the interactive tool currently being used on the canvas. |
|
Returns the currently active tool. |
|
Unset the current tool. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsPlotCanvas. See the FAQ for more details.
Centers the plot on the plot point corresponding to x, y in canvas units. |
|
Returns the coordinate reference system (CRS) for map coordinates used by the canvas. |
|
Pans the plot contents by dx, dy in canvas units. |
|
Updates and redraws the plot. |
|
Scales the plot by a specified scale factor. |
|
Snap a canvas point to the plot |
|
Converts a point in map coordinates to the associated canvas point. |
|
Converts a point on the canvas to the associated map coordinate. |
|
Zoom plot from a mouse wheel event. |
|
Zooms the plot to the specified rect in canvas units. |
Signals
Emitted before the canvas context menu will be shown. |
|
Emitted whenever the visible area of the plot is changed. |
|
Emitted when the plot tool is changed. |
|
Emitted in the destructor when the canvas is about to be deleted, but is still in a perfectly valid state. |
- class qgis.gui.QgsPlotCanvas[source]¶
Bases:
QGraphicsView
- __init__(parent: QWidget | None = None)
Constructor for QgsPlotCanvas, with the specified
parent
widget.- Parameters:
parent (Optional[QWidget] = None)
- virtual centerPlotOn(self, x: float, y: float)[source]¶
Centers the plot on the plot point corresponding to
x
,y
in canvas units.The default implementation does nothing.
- Parameters:
x (float)
y (float)
- signal contextMenuAboutToShow(menu: QMenu, event: QgsPlotMouseEvent)[source]¶
Emitted before the canvas context menu will be shown. Can be used to extend the context menu.
- Parameters:
menu (QMenu)
event (QgsPlotMouseEvent)
- virtual crs(self) QgsCoordinateReferenceSystem [source]¶
Returns the coordinate reference system (CRS) for map coordinates used by the canvas.
May return an invalid CRS if no CRS is associated with the canvas.
- Return type:
- virtual panContentsBy(self, dx: float, dy: float)[source]¶
Pans the plot contents by
dx
,dy
in canvas units.The default implementation does nothing.
- Parameters:
dx (float)
dy (float)
- virtual scalePlot(self, factor: float)[source]¶
Scales the plot by a specified
scale
factor.The default implementation does nothing.
- Parameters:
factor (float)
- setTool(self, tool: QgsPlotTool | None)[source]¶
Sets the interactive tool currently being used on the canvas.
- Parameters:
tool (Optional[QgsPlotTool])
- virtual snapToPlot(self, point: QPoint) QgsPointXY [source]¶
Snap a canvas point to the plot
Returns an empty point if snapping was not possible.
- Parameters:
point (QPoint) – point in canvas coordinates
- Return type:
- virtual toCanvasCoordinates(self, point: QgsPoint) QgsPointXY [source]¶
Converts a
point
in map coordinates to the associated canvas point.May return an empty point if the map point cannot be converted to a canvas point.
- Parameters:
point (QgsPoint)
- Return type:
- virtual toMapCoordinates(self, point: QgsPointXY) QgsPoint [source]¶
Converts a
point
on the canvas to the associated map coordinate.May return an empty point if the canvas point cannot be converted to a map point.
- Parameters:
point (QgsPointXY)
- Return type:
- tool(self) QgsPlotTool | None [source]¶
Returns the currently active tool.
- Return type:
Optional[QgsPlotTool]
- signal toolChanged(newTool: QgsPlotTool)[source]¶
Emitted when the plot tool is changed.
- Parameters:
newTool (QgsPlotTool)
- unsetTool(self, tool: QgsPlotTool | None)[source]¶
Unset the current
tool
.This is called from destructor of plot tools to make sure that this map tool won’t be used any more.
You don’t have to call it manually,
QgsPlotTool
takes care of it.- Parameters:
tool (Optional[QgsPlotTool])
- virtual wheelZoom(self, event: QWheelEvent | None)[source]¶
Zoom plot from a mouse wheel
event
.The default implementation does nothing.
- Parameters:
event (Optional[QWheelEvent])