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. |
- class qgis.gui.QgsPlotCanvas[source]¶
Bases:
QGraphicsView- __init__(parent: QWidget | None = None)
Constructor for QgsPlotCanvas, with the specified
parentwidget.- Parameters:
parent (Optional[QWidget] = None)
- virtual centerPlotOn(self, x: float, y: float)[source]¶
Centers the plot on the plot point corresponding to
x,yin canvas units.The default implementation does nothing.
- Parameters:
x (float)
y (float)
- signal contextMenuAboutToShow[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- 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,dyin canvas units.The default implementation does nothing.
- Parameters:
dx (float)
dy (float)
- signal plotAreaChanged[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- virtual scalePlot(self, factor: float)[source]¶
Scales the plot by a specified
scalefactor.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
pointin 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
pointon 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[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- 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,
QgsPlotTooltakes 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])
- signal willBeDeleted[source]¶
pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.