Class: QgsHistogram¶
Calculator for a numeric histogram from a list of values.
Methods
Returns a list of edges for the histogram for a specified number of bins. |
|
Returns the calculated list of the counts for the histogram bins. |
|
Calculates the optimal bin width using the Freedman-Diaconis rule. |
|
Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule. |
|
Assigns numeric source values for the histogram. |
- class qgis.core.QgsHistogram[source]¶
Bases:
object
- binEdges(self, bins: int) List[float] ¶
Returns a list of edges for the histogram for a specified number of bins. This list will be length bins + 1, as both the first and last value are also included.
- Parameters:
bins (int) – number of bins
- Return type:
List[float]
- Returns:
list of bin edges
Note
values must first be specified using
setValues()
- counts(self, bins: int) List[int] ¶
Returns the calculated list of the counts for the histogram bins.
- Parameters:
bins (int) – number of histogram bins
- Return type:
List[int]
- Returns:
list of histogram counts
Note
values must first be specified using
setValues()
- optimalBinWidth(self) float [source]¶
Calculates the optimal bin width using the Freedman-Diaconis rule. Bins widths are determined by the inter-quartile range of values and the number of values.
- Return type:
float
- Returns:
optimal width for bins
See also
Note
values must first be specified using
setValues()
- optimalNumberBins(self) int [source]¶
Returns the optimal number of bins for the source values, calculated using the Freedman-Diaconis rule. The number of bins are determined by the inter-quartile range of values and the number of values.
- Return type:
int
- Returns:
optimal number of bins
See also
Note
values must first be specified using
setValues()
- setValues(self, values: Iterable[float])[source]¶
Assigns numeric source values for the histogram.
- Parameters:
values (Iterable[float]) – list of doubles
- setValues(self, layer: QgsVectorLayer | None, fieldOrExpression: str | None, feedback: QgsFeedback | None = None) bool [source]
Assigns numeric source values for the histogram from a vector layer’s field or as the result of an expression.
- Parameters:
layer (Optional[QgsVectorLayer]) – vector layer
fieldOrExpression (Optional[str]) – field name or expression to be evaluated
feedback (Optional[QgsFeedback] = None) – optional feedback object to allow cancellation of calculation
- Return type:
bool
- Returns:
True
if values were successfully set