Class: QgsColorBrewerColorRamp

Color ramp utilising “Color Brewer” preset color schemes.

Class Hierarchy

Inheritance diagram of qgis.core.QgsColorBrewerColorRamp

Base classes

QgsColorRamp

Abstract base class for color ramps.

Methods

colors

Returns the number of colors in the ramp.

loadPalette

Generates the scheme using the current name and number of colors

schemeName

Returns the name of the color brewer color scheme.

setColors

Sets the number of colors in the ramp.

setSchemeName

Sets the name of the color brewer color scheme.

Static Methods

create

Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map.

listSchemeNames

Returns a list of all valid color brewer scheme names.

listSchemeVariants

Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name

typeString

Returns the string identifier for QgsColorBrewerColorRamp.

class qgis.core.QgsColorBrewerColorRamp[source]

Bases: QgsColorRamp

__init__(schemeName: str | None = '', colors: int = DEFAULT_COLORBREWER_COLORS, inverted: bool = False)

Constructor for QgsColorBrewerColorRamp

Parameters:
  • schemeName (Optional[str] = '') – color brewer scheme name

  • colors (int = DEFAULT_COLORBREWER_COLORS) – number of colors in ramp

  • inverted (bool = False) – invert ramp ordering

__init__(a0: QgsColorBrewerColorRamp)
Parameters:

a0 (QgsColorBrewerColorRamp)

colors(self) int[source]

Returns the number of colors in the ramp.

See also

setColors()

Return type:

int

static create(properties: Dict[str, Any] = {}) QgsColorRamp | None[source]

Returns a new QgsColorBrewerColorRamp color ramp created using the properties encoded in a string map.

Parameters:

properties (Dict[str, Any] = {}) – color ramp properties

See also

properties()

Return type:

Optional[QgsColorRamp]

static listSchemeNames() List[str][source]

Returns a list of all valid color brewer scheme names.

Return type:

List[str]

static listSchemeVariants(schemeName: str | None) List[int]

Returns a list of the valid variants (numbers of colors) for a specified color brewer scheme name

Parameters:

schemeName (Optional[str]) – color brewer scheme name

Return type:

List[int]

loadPalette(self)[source]

Generates the scheme using the current name and number of colors

schemeName(self) str[source]

Returns the name of the color brewer color scheme.

See also

setSchemeName()

Return type:

str

setColors(self, colors: int)[source]

Sets the number of colors in the ramp.

Parameters:

colors (int) – number of colors. Must match a valid value for the scheme, which can be retrieved using listSchemeVariants()

See also

colors()

setSchemeName(self, schemeName: str | None)[source]

Sets the name of the color brewer color scheme.

Parameters:

schemeName (Optional[str]) – scheme name, must match a valid color brewer scheme name

See also

schemeName()

static typeString() str[source]

Returns the string identifier for QgsColorBrewerColorRamp.

Added in version 3.16.

Return type:

str