Skip to content

Class QAccelPlot::Colormap

ClassList > QAccelPlot > Colormap

Maps data values to colors: a color ramp plus the rule that places a value on it. More...

  • #include <Colormap.hpp>

Inherits the following classes: QObject, QQmlParserStatus

Inheritance diagram

flowchart TB
  classQAccelPlot_1_1Colormap["QAccelPlot::Colormap"]

  external_base_classQAccelPlot_1_1Colormap_1["QObject"]
  external_base_classQAccelPlot_1_1Colormap_1 --> classQAccelPlot_1_1Colormap
  external_base_classQAccelPlot_1_1Colormap_2["QQmlParserStatus"]
  external_base_classQAccelPlot_1_1Colormap_2 --> classQAccelPlot_1_1Colormap

Public Types

Type Name
enum Preset
Built-in color ramps.

Public Properties

Type Name
property bool logScale
Whether values are placed on the ramp in log10 instead of linearly. Default: false .
property qreal max
Value at ramp position 1. Unset (NaN) resolves it from the data. Default: unset.
property qreal min
Value at ramp position 0. Unset (NaN) resolves it from the data. Default: unset.
property Preset preset
Built-in color ramp. Ignored when stops is non-empty. Default:Viridis .
property bool reversed
Whether the ramp runs from its last color to its first. Applies to preset andstops alike. Default:false .
property QQmlListProperty< QObject > stops
Custom ramp as a list of objects with position andcolor , such asGradientStop . Overridespreset when non-empty. Stops are read again once the component is complete. The ramp follows changes to a stop that notifies them, to aGradientStop inside aGradient , and to aGradientStop declared in this list.

Public Signals

Type Name
signal void colormapChanged
Emitted when the ramp, its bounds, or logScale changes.

Public Functions

Type Name
Colormap (QObject * parent=nullptr)
Constructs a Colormap with the given__parent .
bool logScale () const
Returns true when values are placed on the ramp in log10.
qreal max () const
Returns the fixed upper bound, or NaN when it is resolved from the data.
qreal min () const
Returns the fixed lower bound, or NaN when it is resolved from the data.
Preset preset () const
Returns the built-in ramp.
const std::vector< GradientStopData > & resolvedStops () const
Returns the resolved ramp stops, in position order and covering [0, 1].
bool reversed () const
Returns whether the ramp is reversed.
void setLogScale (bool on)
Sets log-scale placement to on .
void setMax (qreal value)
Sets the fixed upper bound to value . NaN resolves it from the data.
void setMin (qreal value)
Sets the fixed lower bound to value . NaN resolves it from the data.
void setPreset (Preset preset)
Sets the built-in ramp to preset .
Q_INVOKABLE void setRange (qreal min, qreal max)
Sets both bounds to min and__max with a singlecolormapChanged() . NaN unsets a bound.
void setReversed (bool reversed)
Sets whether the ramp is reversed to reversed .
QQmlListProperty< QObject > stops ()
Returns the custom ramp stops, empty when the preset supplies the ramp.

Protected Functions

Type Name
void classBegin () override
Does nothing; part of QQmlParserStatus .
void componentComplete () override
Reads the stops again after their bindings are evaluated.

Detailed Description

A colormap has no geometry. It is a one-dimensional ramp addressed by a normalized coordinate in [0, 1], and logScale decides how a value reaches that coordinate. Series that color by value, such as PointCloud and HeatmapSeries, index the ramp with each value. Effects that paint a ramp across the plot, such as GradientFill and GradientStroke, supply the coordinate from a position instead and own that geometry themselves, so they use only the ramp.

The ramp comes from preset, or from stops when a custom ramp is given. min and max bound the value range; leaving either unset resolves it from the data, so one colormap can be shared between series that resolve different ranges. Each series reports what it resolved through ColormappedSeries::dataValueMin() and ColormappedSeries::dataValueMax().

See also: PointCloud, HeatmapSeries, BarSeries, GradientFill, GradientStroke

Public Types Documentation

enum Preset

Built-in color ramps.

enum QAccelPlot::Colormap::Preset {
    Viridis,
    Plasma,
    Inferno,
    Magma,
    Grayscale,
    Rainbow
};

The perceptually uniform ramps are sampled from the matplotlib originals. Prefer them over Rainbow, whose uneven lightness invents boundaries that are not in the data.


Public Properties Documentation

property logScale

Whether values are placed on the ramp in log10 instead of linearly. Default: false .

bool QAccelPlot::Colormap::logScale;

Values at or below zero are unmapped. A ColorBar showing the colormap gets decade ticks.


property max

Value at ramp position 1. Unset (NaN) resolves it from the data. Default: unset.

qreal QAccelPlot::Colormap::max;


property min

Value at ramp position 0. Unset (NaN) resolves it from the data. Default: unset.

qreal QAccelPlot::Colormap::min;


property preset

Built-in color ramp. Ignored when stops is non-empty. Default:Viridis .

Preset QAccelPlot::Colormap::preset;


property reversed

Whether the ramp runs from its last color to its first. Applies to preset andstops alike. Default:false .

bool QAccelPlot::Colormap::reversed;


property stops

Custom ramp as a list of objects with position andcolor , such asGradientStop . Overridespreset when non-empty. Stops are read again once the component is complete. The ramp follows changes to a stop that notifies them, to aGradientStop inside aGradient , and to aGradientStop declared in this list.

QQmlListProperty<QObject> QAccelPlot::Colormap::stops;


Public Signals Documentation

signal colormapChanged

Emitted when the ramp, its bounds, or logScale changes.

void QAccelPlot::Colormap::colormapChanged;


Public Functions Documentation

function Colormap

Constructs a Colormap with the given__parent .

explicit QAccelPlot::Colormap::Colormap (
    QObject * parent=nullptr
) 


function logScale

Returns true when values are placed on the ramp in log10.

bool QAccelPlot::Colormap::logScale () const


function max

Returns the fixed upper bound, or NaN when it is resolved from the data.

qreal QAccelPlot::Colormap::max () const


function min

Returns the fixed lower bound, or NaN when it is resolved from the data.

qreal QAccelPlot::Colormap::min () const


function preset

Returns the built-in ramp.

Preset QAccelPlot::Colormap::preset () const


function resolvedStops

Returns the resolved ramp stops, in position order and covering [0, 1].

const std::vector< GradientStopData > & QAccelPlot::Colormap::resolvedStops () const

Custom stops when set, otherwise the preset ramp, flipped when reversed is set.


function reversed

Returns whether the ramp is reversed.

bool QAccelPlot::Colormap::reversed () const


function setLogScale

Sets log-scale placement to on .

void QAccelPlot::Colormap::setLogScale (
    bool on
) 


function setMax

Sets the fixed upper bound to value . NaN resolves it from the data.

void QAccelPlot::Colormap::setMax (
    qreal value
) 


function setMin

Sets the fixed lower bound to value . NaN resolves it from the data.

void QAccelPlot::Colormap::setMin (
    qreal value
) 


function setPreset

Sets the built-in ramp to preset .

void QAccelPlot::Colormap::setPreset (
    Preset preset
) 


function setRange

Sets both bounds to min and__max with a singlecolormapChanged() . NaN unsets a bound.

Q_INVOKABLE void QAccelPlot::Colormap::setRange (
    qreal min,
    qreal max
) 


function setReversed

Sets whether the ramp is reversed to reversed .

void QAccelPlot::Colormap::setReversed (
    bool reversed
) 


function stops

Returns the custom ramp stops, empty when the preset supplies the ramp.

QQmlListProperty< QObject > QAccelPlot::Colormap::stops () 


Protected Functions Documentation

function classBegin

Does nothing; part of QQmlParserStatus .

void QAccelPlot::Colormap::classBegin () override


function componentComplete

Reads the stops again after their bindings are evaluated.

void QAccelPlot::Colormap::componentComplete () override



The documentation for this class was generated from the following file QAccelPlot/src/QAccelPlot/effects/Colormap.hpp