Class: Qgs2DPlot

class qgis.core.Qgs2DPlot

Bases: QgsPlot

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

The base class is responsible for rendering the axis, grid lines and chart area. Subclasses can implement the renderContent() method to render their actual plot content.

Warning

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

New in version 3.26.

Qgs2DPlot() Constructor for Qgs2DPlot.

Methods

calculateOptimisedIntervals

Automatically sets the grid and label intervals to optimal values for display in the given render context.

chartBackgroundSymbol

Returns the fill symbol used to render the background of the chart.

chartBorderSymbol

Returns the symbol used to render the border of the chart.

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).

margins

Returns the margins of the plot area (in millimeters)

readXml

param element:

render

Renders the plot.

renderContent

Renders the plot content.

setChartBackgroundSymbol

Sets the fill symbol used to render the background of the chart.

setChartBorderSymbol

Sets the symbol used to render the border of the chart.

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).

setXMaximum

Sets the maximum value of the x axis.

setXMinimum

Sets the minimum value of the x axis.

setYMaximum

Sets the maximum value of the y axis.

setYMinimum

Sets the minimum value of the y axis.

size

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

writeXml

Qgs2DPlot cannot be copied

xAxis

Returns a reference to the plot's x axis.

xMaximum

Returns the maximum value of the x axis.

xMinimum

Returns the minimum value of the x axis.

yAxis

Returns a reference to the plot's y axis.

yMaximum

Returns the maximum value of the y axis.

yMinimum

Returns the minimum value of the y axis.

calculateOptimisedIntervals(self, context: QgsRenderContext)

Automatically sets the grid and label intervals to optimal values for display in the given render context.

Intervals will be calculated in order to avoid overlapping axis labels and to ensure round values are shown.

Parameters:

context (QgsRenderContext) –

chartBackgroundSymbol(self) QgsFillSymbol

Returns the fill symbol used to render the background of the chart.

Return type:

QgsFillSymbol

chartBorderSymbol(self) QgsFillSymbol

Returns the symbol used to render the border of the chart.

Return type:

QgsFillSymbol

interiorPlotArea(self, context: QgsRenderContext) QRectF

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:

context (QgsRenderContext) –

Return type:

QRectF

margins(self) QgsMargins

Returns the margins of the plot area (in millimeters)

See also

setMargins()

Return type:

QgsMargins

readXml(self, element: QDomElement, context: QgsReadWriteContext) bool
Parameters:
Return type:

bool

render(self, context: QgsRenderContext)

Renders the plot.

Parameters:

context (QgsRenderContext) –

renderContent(self, context: QgsRenderContext, plotArea: QRectF)

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:
setChartBackgroundSymbol(self, symbol: QgsFillSymbol)

Sets the fill symbol used to render the background of the chart.

Ownership of symbol is transferred to the plot.

Parameters:

symbol (QgsFillSymbol) –

setChartBorderSymbol(self, symbol: QgsFillSymbol)

Sets the symbol used to render the border of the chart.

Ownership of symbol is transferred to the plot.

Parameters:

symbol (QgsFillSymbol) –

setMargins(self, margins: QgsMargins)

Sets the margins of the plot area (in millimeters)

See also

setMargins()

Parameters:

margins (QgsMargins) –

setSize(self, size: QSizeF)

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

See also

size()

Parameters:

size (QSizeF) –

setXMaximum(self, maximum: float)

Sets the maximum value of the x axis.

See also

xMaximum()

Parameters:

maximum (float) –

setXMinimum(self, minimum: float)

Sets the minimum value of the x axis.

See also

xMinimum()

Parameters:

minimum (float) –

setYMaximum(self, maximum: float)

Sets the maximum value of the y axis.

See also

yMaximum()

Parameters:

maximum (float) –

setYMinimum(self, minimum: float)

Sets the minimum value of the y axis.

See also

yMinimum()

Parameters:

minimum (float) –

size(self) QSizeF

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

writeXml(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool

Qgs2DPlot cannot be copied

Parameters:
Return type:

bool

xAxis(self) QgsPlotAxis

Returns a reference to the plot’s x axis.

See also

yAxis()

Return type:

QgsPlotAxis

xMaximum(self) float

Returns the maximum value of the x axis.

See also

setXMaximum()

Return type:

float

xMinimum(self) float

Returns the minimum value of the x axis.

See also

setXMinimum()

Return type:

float

yAxis(self) QgsPlotAxis

Returns a reference to the plot’s y axis.

See also

xAxis()

Return type:

QgsPlotAxis

yMaximum(self) float

Returns the maximum value of the y axis.

See also

setYMaximum()

Return type:

float

yMinimum(self) float

Returns the minimum value of the y axis.

See also

setYMinimum()

Return type:

float