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
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. |
|
Sets the interactive tool currently being used on the canvas. |
|
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. |
|
Returns the currently active tool. |
|
Unset the current tool. |
|
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)
- 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)
- 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:
- 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)
- 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])
- 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:
- 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:
- 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])
- wheelZoom(self, event: QWheelEvent | None)[source]¶
Zoom plot from a mouse wheel
event
.The default implementation does nothing.
- Parameters:
event (Optional[QWheelEvent])