Class: Qgs2DPlot

Base class for 2-dimensional plot/chart/graphs.

Warning

This class is not considered stable API, and may change in future!

Added in version 3.26.

Class Hierarchy

Inheritance diagram of qgis.core.Qgs2DPlot

Base classes

QgsPlot

Base class for plot/chart/graphs.

Subclasses

Qgs2DXyPlot

Base class for 2-dimensional plot/chart/graphs with an X and Y axes.

Methods

margins

Returns the margins of the plot area (in millimeters)

setMargins

Sets the margins of the plot area (in millimeters)

setSize

Sets the overall size of the plot (including titles and over components which sit outside the plot area).

size

Returns the overall size of the plot (in millimeters) (including titles and other components which sit outside the plot area).

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of Qgs2DPlot. See the FAQ for more details.

interiorPlotArea

Returns the area of the plot which corresponds to the actual plot content (excluding all titles and other components which sit outside the plot area).

render

Renders the plot.

renderContent

Renders the plot content.

class qgis.core.Qgs2DPlot[source]

Bases: QgsPlot

__init__()

Constructor for Qgs2DPlot.

virtual interiorPlotArea(self, context: QgsRenderContext, plotContext: QgsPlotRenderContext) QRectF[source]

Returns the area of the plot which corresponds to the actual plot content (excluding all titles and other components which sit outside the plot area).

Parameters:
Return type:

QRectF

margins(self) QgsMargins

Returns the margins of the plot area (in millimeters)

See also

setMargins()

Return type:

QgsMargins

virtual render(self, context: QgsRenderContext, plotContext: QgsPlotRenderContext, plotData: QgsPlotData = QgsPlotData())[source]

Renders the plot.

Parameters:
virtual renderContent(self, context: QgsRenderContext, plotContext: QgsPlotRenderContext, plotArea: QRectF, plotData: QgsPlotData = QgsPlotData())[source]

Renders the plot content.

Subclasses can implement this method to render the actual plot content (e.g. bar charts, scatter plots). This method will be called after the chart background and grid are rendered, but before the chart border is rendered.

The default implementation does nothing.

The plotArea argument specifies that area of the plot which corresponds to the actual plot content. Implementations should take care to scale values accordingly to render points correctly inside this plot area.

Parameters:
setMargins(self, margins: QgsMargins)[source]

Sets the margins of the plot area (in millimeters)

See also

setMargins()

Parameters:

margins (QgsMargins)

setSize(self, size: QSizeF)[source]

Sets the overall size of the plot (including titles and over components which sit outside the plot area).

See also

size()

Parameters:

size (QSizeF)

size(self) QSizeF[source]

Returns the overall size of the plot (in millimeters) (including titles and other components which sit outside the plot area).

See also

setSize()

Return type:

QSizeF