Subgroup: Color

Class: QgsColorRampTransformer

class qgis.core.QgsColorRampTransformer

Bases: qgis._core.QgsPropertyTransformer

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.
create Factory method for creating a new property transformer of the specified type.
curveTransform Returns the curve transform applied to input values before they are transformed by the individual transform subclasses.
fromExpression Attempts to parse an expression into a corresponding property transformer.
loadVariant
maxValue Returns the maximum value expected by the transformer.
minValue Returns the minimum value expected by the transformer.
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.
setCurveTransform Sets a curve transform to apply to input values before they are transformed by the individual transform subclasses.
setMaxValue Sets the maximum value expected by the transformer.
setMinValue Sets the minimum value expected by the transformer.
setNullColor Sets the color corresponding to a null value.
setRampName Sets the color ramp’s name.
toExpression
toVariant
transform
transformNumeric
transformerType

Attributes

ColorRampTransformer
GenericNumericTransformer
SizeScaleTransformer
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

nullSize()

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