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
Automatically sets the grid and label intervals to optimal values for display in the given render
context
.Returns the fill symbol used to render the background of the chart.
Returns the symbol used to render the border of the chart.
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).
Returns the margins of the plot area (in millimeters)
- param element
Renders the plot.
Renders the plot content.
Sets the fill
symbol
used to render the background of the chart.Sets the
symbol
used to render the border of the chart.Sets the
margins
of the plot area (in millimeters)Sets the overall
size
of the plot (including titles and over components which sit outside the plot area).Sets the
maximum
value of the x axis.Sets the
minimum
value of the x axis.Sets the
maximum
value of the y axis.Sets the
minimum
value of the y axis.Returns the overall size of the plot (in millimeters) (including titles and other components which sit outside the plot area).
Qgs2DPlot cannot be copied
Returns a reference to the plot's x axis.
Returns the maximum value of the x axis.
Returns the minimum value of the x axis.
Returns a reference to the plot's y axis.
Returns the maximum value of the y axis.
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.
See also
- Return type
- chartBorderSymbol(self) QgsFillSymbol ¶
Returns the symbol used to render the border of the chart.
See also
- Return type
- 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
- Return type
- readXml(self, element: QDomElement, context: QgsReadWriteContext) bool ¶
- Parameters
element (QDomElement) –
context (QgsReadWriteContext) –
- 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
context (QgsRenderContext) –
plotArea (QRectF) –
- setChartBackgroundSymbol(self, symbol: QgsFillSymbol)¶
Sets the fill
symbol
used to render the background of the chart.Ownership of
symbol
is transferred to the plot.See also
- 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.See also
- Parameters
symbol (QgsFillSymbol) –
- setMargins(self, margins: QgsMargins)¶
Sets the
margins
of the plot area (in millimeters)See also
- 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
- Parameters
size (QSizeF) –
- setXMaximum(self, maximum: float)¶
Sets the
maximum
value of the x axis.See also
- Parameters
maximum (float) –
- setXMinimum(self, minimum: float)¶
Sets the
minimum
value of the x axis.See also
- Parameters
minimum (float) –
- setYMaximum(self, maximum: float)¶
Sets the
maximum
value of the y axis.See also
- Parameters
maximum (float) –
- setYMinimum(self, minimum: float)¶
Sets the
minimum
value of the y axis.See also
- 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
- Return type
QSizeF
- writeXml(self, element: QDomElement, document: QDomDocument, context: QgsReadWriteContext) bool ¶
Qgs2DPlot cannot be copied
- Parameters
element (QDomElement) –
document (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
bool
- xAxis(self) QgsPlotAxis ¶
Returns a reference to the plot’s x axis.
See also
- Return type
- xMaximum(self) float ¶
Returns the maximum value of the x axis.
See also
- Return type
float
- xMinimum(self) float ¶
Returns the minimum value of the x axis.
See also
- Return type
float
- yAxis(self) QgsPlotAxis ¶
Returns a reference to the plot’s y axis.
See also
- Return type
- yMaximum(self) float ¶
Returns the maximum value of the y axis.
See also
- Return type
float
- yMinimum(self) float ¶
Returns the minimum value of the y axis.
See also
- Return type
float