Class: QgsGraduatedSymbolRenderer¶
-
class
qgis.core.
QgsGraduatedSymbolRenderer
(attrName: str = '', ranges: object = QgsRangeList())¶ Bases:
qgis._core.QgsFeatureRenderer
Enums
Methods
Add a breakpoint by splitting existing classes so that the specified value becomes a break between two classes.
Returns if we want to have a central class astride the pivot value
Compute the equal interval classification
Reset the label decimal places to a numberbased on the minimum class interval
creates a QgsGraduatedSymbolRenderer from an existing renderer.
create renderer from XML element
Creates a new graduated renderer.
Returns configuration of appearance of legend when using data-defined size for marker symbols.
Returns the method used for graduation (either size or color)
Returns the label format used to generate default classification labels
Returns the matching legend key for a value.
Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint Does not put a break on the symmetryPoint.
Returns the max symbol size when graduated by size
Returns the min symbol size when graduated by size
Moves the category at index position from to index position to.
Tests whether classes assigned to the renderer have gaps between the ranges.
Tests whether classes assigned to the renderer have ranges which overlap.
Set if we want a central class astride the pivot value
Configures appearance of legend when renderer is configured to use data-defined size for marker symbols.
set the method used for graduation (either size or color)
Set the label format used to generate default classification labels
Sets the source color ramp.
Sets the source symbol for the renderer, which is the base symbol used for the each classes’ symbol before applying the classes’ color.
set varying symbol size for classes
Set the pivot point
Set if we want to classify symmetric around a given value
Returns the source color ramp, from which each classes’ color is derived.
Returns the renderer’s source symbol, which is the base symbol used for the each classes’ symbol before applying the classes’ color.
Gets the symbol which is used to represent
value
.Returns the pivot value for symmetric classification
Recalculate classes for a layer
Update the color ramp used.
New in version 2.5.
Update all the symbols but leave breaks and colors.
Returns if we want to classify symmetric around a given value
Signals
Attributes
-
Custom
= 5¶
-
EqualInterval
= 0¶
-
GraduatedColor
= 0¶
-
class
GraduatedMethod
¶ Bases:
int
-
GraduatedSize
= 1¶
-
Jenks
= 2¶
-
class
Mode
¶ Bases:
int
-
Pretty
= 4¶
-
Quantile
= 1¶
-
StdDev
= 3¶
-
addBreak
(self, breakValue: float, updateSymbols: bool = True)¶ Add a breakpoint by splitting existing classes so that the specified value becomes a break between two classes.
- Parameters
breakValue – position to insert break
updateSymbols – set to true to reapply ramp colors to the new symbol ranges
New in version 2.9.
-
addClass
(self, symbol: QgsSymbol)¶
-
addClassLowerUpper
(self, lower: float, upper: float)¶ Note
available in Python bindings as addClassLowerUpper
-
addClassRange
(self, range: QgsRendererRange)¶ Note
available in Python bindings as addClassRange
-
astride
(self) → bool¶ Returns if we want to have a central class astride the pivot value
New in version 3.4.
-
calcEqualIntervalBreaks
(minimum: float, maximum: float, classes: int, useSymmetricMode: bool, symmetryPoint: float, astride: bool) → List[float]¶ Compute the equal interval classification
- Parameters
minimum – The minimum value of the distribution
maximum – The maximum value of the distribution
classes – The number of classes desired
useSymmetricMode – A bool indicating if we want to have classes and hence colors ramp symmetric around a value
symmetryPoint – The point around which we want a symmetry
astride – A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
-
calculateLabelPrecision
(self, updateRanges: bool = True)¶ Reset the label decimal places to a numberbased on the minimum class interval
- Parameters
updateRanges – if true then ranges currently using the default label will be updated
New in version 2.6.
-
capabilities
(self) → QgsFeatureRenderer.Capabilities¶
-
checkLegendSymbolItem
(self, key: str, state: bool = True)¶
-
classAttribute
(self) → str¶
-
clone
(self) → QgsGraduatedSymbolRenderer¶
-
convertFromRenderer
(renderer: QgsFeatureRenderer) → QgsGraduatedSymbolRenderer¶ creates a QgsGraduatedSymbolRenderer from an existing renderer.
- Returns
a new renderer if the conversion was possible, otherwise 0.
New in version 2.6.
-
convertSymbolRotation
()¶
-
convertSymbolSizeScale
()¶
-
copyRendererData
()¶
-
create
(element: QDomElement, context: QgsReadWriteContext) → QgsFeatureRenderer¶ create renderer from XML element
-
createRenderer
(vlayer: QgsVectorLayer, attrName: str, classes: int, mode: QgsGraduatedSymbolRenderer.Mode, symbol: QgsSymbol, ramp: QgsColorRamp, legendFormat: QgsRendererRangeLabelFormat = QgsRendererRangeLabelFormat(), useSymmetricMode: bool = False, symmetryPoint: float = 0, listForCboPrettyBreaks: Iterable[str] = [], astride: bool = False) → QgsGraduatedSymbolRenderer¶ Creates a new graduated renderer.
- Parameters
vlayer – vector layer
attrName – attribute to classify
classes – number of classes
mode – classification mode
symbol – base symbol
ramp – color ramp for classes
legendFormat –
useSymmetricMode – A bool indicating if we want to have classes and hence colors ramp symmetric around a value
symmetryPoint – The value around which the classes will be symmetric if useSymmetricMode is checked
listForCboPrettyBreaks – The list of potential pivot values for symmetric mode with prettybreaks mode
astride – A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
- Returns
new QgsGraduatedSymbolRenderer object
-
dataDefinedSizeLegend
(self) → QgsDataDefinedSizeLegend¶ Returns configuration of appearance of legend when using data-defined size for marker symbols. Will return null if the functionality is disabled.
New in version 3.0.
-
deleteAllClasses
(self)¶
-
deleteClass
(self, idx: int)¶
-
dump
(self) → str¶
-
filterNeedsGeometry
(self) → bool¶
-
graduatedMethod
(self) → QgsGraduatedSymbolRenderer.GraduatedMethod¶ Returns the method used for graduation (either size or color)
New in version 2.10.
-
labelFormat
(self) → QgsRendererRangeLabelFormat¶ Returns the label format used to generate default classification labels
New in version 2.6.
-
legendClassificationAttribute
(self) → str¶
-
legendKeyForValue
(self, value: float) → str¶ Returns the matching legend key for a value.
-
legendKeysForFeature
(self, feature: QgsFeature, context: QgsRenderContext) → Set[str]¶
-
legendSymbolItemChecked
(self, key: str) → bool¶
-
legendSymbolItems
(self) → object¶
-
legendSymbolItemsCheckable
(self) → bool¶
-
makeBreaksSymmetric
(breaks: Iterable[float], symmetryPoint: float, astride: bool)¶ Remove the breaks that are above the existing opposite sign classes to keep colors symmetrically balanced around symmetryPoint Does not put a break on the symmetryPoint. This is done before.
- Parameters
breaks – The breaks of an already-done classification
symmetryPoint – The point around which we want a symmetry
astride – A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
New in version 3.4.
-
maxSymbolSize
(self) → float¶ Returns the max symbol size when graduated by size
New in version 2.10.
-
minSymbolSize
(self) → float¶ Returns the min symbol size when graduated by size
New in version 2.10.
-
mode
(self) → QgsGraduatedSymbolRenderer.Mode¶
-
moveClass
(self, from_: int, to: int)¶ Moves the category at index position from to index position to.
-
originalSymbolForFeature
(self, feature: QgsFeature, context: QgsRenderContext) → QgsSymbol¶
-
ranges
(self) → object¶
-
rangesHaveGaps
(self) → bool¶ Tests whether classes assigned to the renderer have gaps between the ranges.
- Returns
true if ranges have gaps
New in version 2.10.
-
rangesOverlap
(self) → bool¶ Tests whether classes assigned to the renderer have ranges which overlap.
- Returns
true if ranges overlap
New in version 2.10.
-
renderFeatureWithSymbol
()¶
-
renderVertexMarker
()¶
-
renderVertexMarkerPolygon
()¶
-
renderVertexMarkerPolyline
()¶
-
save
(self, doc: QDomDocument, context: QgsReadWriteContext) → QDomElement¶
-
setAstride
(self, astride: bool)¶ Set if we want a central class astride the pivot value
New in version 3.4.
-
setClassAttribute
(self, attr: str)¶
-
setDataDefinedSizeLegend
(self, settings: QgsDataDefinedSizeLegend)¶ Configures appearance of legend when renderer is configured to use data-defined size for marker symbols. This allows configuring for which values (symbol sizes) should be shown in the legend, whether to display different symbol sizes collapsed in one legend node or separated across multiple legend nodes etc.
When renderer does not use data-defined size or does not use marker symbols, these settings will be ignored. Takes ownership of the passed settings objects. Null pointer is a valid input that disables data-defined size legend.
New in version 3.0.
-
setGraduatedMethod
(self, method: QgsGraduatedSymbolRenderer.GraduatedMethod)¶ set the method used for graduation (either size or color)
New in version 2.10.
-
setLabelFormat
(self, labelFormat: QgsRendererRangeLabelFormat, updateRanges: bool = False)¶ Set the label format used to generate default classification labels
- Parameters
labelFormat – The string appended to classification labels
updateRanges – If true then ranges ending with the old unit string are updated to the new.
New in version 2.6.
-
setLegendSymbolItem
(self, key: str, symbol: QgsSymbol)¶
-
setMode
(self, mode: QgsGraduatedSymbolRenderer.Mode)¶
-
setSourceColorRamp
(self, ramp: QgsColorRamp)¶ Sets the source color ramp.
- Parameters
ramp – color ramp. Ownership is transferred to the renderer
-
setSourceSymbol
(self, sym: QgsSymbol)¶ Sets the source symbol for the renderer, which is the base symbol used for the each classes’ symbol before applying the classes’ color.
- Parameters
sym – source symbol, ownership is transferred to the renderer
See also
See also
-
setSymbolSizes
(self, minSize: float, maxSize: float)¶ set varying symbol size for classes
Note
the classes must already be set so that symbols exist
New in version 2.10.
-
setSymmetryPoint
(self, symmetryPoint: float)¶ Set the pivot point
New in version 3.4.
-
setUseSymmetricMode
(self, useSymmetricMode: bool)¶ Set if we want to classify symmetric around a given value
New in version 3.4.
-
sortByLabel
(self, order: Qt.SortOrder = Qt.AscendingOrder)¶
-
sortByValue
(self, order: Qt.SortOrder = Qt.AscendingOrder)¶
-
sourceColorRamp
(self) → QgsColorRamp¶ Returns the source color ramp, from which each classes’ color is derived.
See also
See also
-
sourceSymbol
(self) → QgsSymbol¶ Returns the renderer’s source symbol, which is the base symbol used for the each classes’ symbol before applying the classes’ color.
See also
See also
-
startRender
(self, context: QgsRenderContext, fields: QgsFields)¶
-
stopRender
(self, context: QgsRenderContext)¶
-
symbolForFeature
(self, feature: QgsFeature, context: QgsRenderContext) → QgsSymbol¶
-
symbolForValue
(self, value: float) → QgsSymbol¶ Gets the symbol which is used to represent
value
.
-
symbols
(self, context: QgsRenderContext) → object¶
-
symmetryPoint
(self) → float¶ Returns the pivot value for symmetric classification
New in version 3.4.
-
toSld
(self, doc: QDomDocument, element: QDomElement, props: Dict[str, str] = {})¶
-
updateClasses
(self, vlayer: QgsVectorLayer, mode: QgsGraduatedSymbolRenderer.Mode, nclasses: int, useSymmetricMode: bool = False, symmetryPoint: float = 0, astride: bool = False)¶ Recalculate classes for a layer
- Parameters
vlayer – The layer being rendered (from which data values are calculated)
mode – The calculation mode
nclasses – The number of classes to calculate (approximate for some modes)
useSymmetricMode – A bool indicating if we want to have classes and hence colors ramp symmetric around a value
symmetryPoint – The value around which the classes will be symmetric if useSymmetricMode is checked
astride – A bool indicating if the symmetry is made astride the symmetryPoint or not ( [-1,1] vs. [-1,0][0,1] )
New in version 2.6.
-
updateColorRamp
(self, ramp: QgsColorRamp = None)¶ Update the color ramp used. Also updates all symbols colors. Doesn’t alter current breaks.
- Parameters
ramp – color ramp. Ownership is transferred to the renderer
-
updateRangeLabel
(self, rangeIndex: int, label: str) → bool¶
-
updateRangeLowerValue
(self, rangeIndex: int, value: float) → bool¶
-
updateRangeRenderState
(self, rangeIndex: int, render: bool) → bool¶ New in version 2.5.
-
updateRangeSymbol
(self, rangeIndex: int, symbol: QgsSymbol) → bool¶
-
updateRangeUpperValue
(self, rangeIndex: int, value: float) → bool¶
-
updateSymbols
(self, sym: QgsSymbol)¶ Update all the symbols but leave breaks and colors. This method also sets the source symbol for the renderer.
- Parameters
sym – source symbol to use for classes. Ownership is not transferred.
See also
-
useSymmetricMode
(self) → bool¶ Returns if we want to classify symmetric around a given value
New in version 3.4.
-
usedAttributes
(self, context: QgsRenderContext) → Set[str]¶
-