Subgroup: Color

Class: QgsColorRampTransformer

class qgis.core.QgsColorRampTransformer(minValue: float = 0, maxValue: float = 1, ramp: QgsColorRamp = None, nullColor: Union[QColor, Qt.GlobalColor, QGradient] = QColor(0, 0, 0, 0))

Bases: qgis._core.QgsPropertyTransformer

Constructor for QgsColorRampTransformer.

Parameters:
  • minValue – minimum expected value
  • maxValue – maximum expected value
  • ramp – source color ramp. Ownership is transferred to the transformer.
  • nullColor – color to return for null values

QgsColorRampTransformer(other: QgsColorRampTransformer) Copy constructor

QgsPropertyTransformer subclass for transforming a numeric value into a color from a color ramp.

New in version 3.0: Methods

clone
color Calculates the color corresponding to a specific value.
colorRamp Returns the color ramp used for calculating property colors.
loadVariant
nullColor Returns the color corresponding to a null value.
rampName Returns the color ramp’s name.
setColorRamp Sets the color ramp to use for calculating property colors.
setNullColor Sets the color corresponding to a null value.
setRampName Sets the color ramp’s name.
toExpression
toVariant
transform
transformNumeric
transformerType

Signals

Attributes

clone(self) → QgsColorRampTransformer
color(self, value: float) → QColor

Calculates the color corresponding to a specific value.

Parameters:value – value to calculate color for
Returns:calculated color using transformer’s parameters and type
colorRamp(self) → QgsColorRamp

Returns the color ramp used for calculating property colors.

Returns:color ramp

See also

setColorRamp()

loadVariant(self, definition: Any) → bool
nullColor(self) → QColor

Returns the color corresponding to a null value.

See also

setNullColor()

rampName(self) → str

Returns the color ramp’s name.

See also

setRampName()

setColorRamp(self, ramp: QgsColorRamp)

Sets the color ramp to use for calculating property colors.

Parameters:ramp – color ramp, ownership of ramp is transferred to the transformer.

See also

colorRamp()

setNullColor(self, color: Union[QColor, Qt.GlobalColor, QGradient])

Sets the color corresponding to a null value.

Parameters:color – null color

See also

nullColor()

setRampName(self, name: str)

Sets the color ramp’s name. The ramp name must be set to match a color ramp available in the style database for conversion to expression to work correctly.

See also

rampName()

toExpression(self, baseExpression: str) → str
toVariant(self) → Any
transform(self, context: QgsExpressionContext, value: Any) → Any
transformNumeric()
transformerType(self) → QgsPropertyTransformer.Type