composeui.core.colorscale¶
Color scales: a value’s color between a low and a high, e.g. for a table’s column.
- class composeui.core.colorscale.ColorScale[source]¶
Bases:
objectA scale of colors: the color of a value between
lowandhigh, e.g. a cell’s.colorsare the stops, evenly spaced fromlow’s color tohigh’s, as#rrggbb; a value between two stops takes a color between theirs. A value belowlowtakeslow’s color, and a value abovehightakeshigh’s. None, NaN and text take none.Without
loworhigh, the scale needs a range from elsewhere: a table gives it its column’s, andcolortakes one. Withmiddle, the first half of the stops coverslowtomiddle, and the second halfmiddletohigh, e.g. a diverging scale’s neutral color on zero.sequentialanddivergingbuild the usual scales. The colors are data: the same in every theme.- classmethod sequential(*, low=None, high=None)[source]¶
Build viridis: dark blue for low values, to yellow for high ones.
- Parameters:
- Return type:
- classmethod diverging(*, middle=0.0, low=None, high=None)[source]¶
Build ParaView’s “Cool to Warm”: blue below
middle, gray on it, red above it.- Parameters:
- Return type:
- range(low=None, high=None)[source]¶
Get the scale’s
lowandhigh, each taken from the arguments when it has none.Raise
ValueErrorwhen neither gives it, or for a low above the high.
- position(value, *, low=None, high=None)[source]¶
Get where
valuefalls on the scale, from 0 (low) to 1 (high), clamped.lowandhighare the range of a scale without its own (seerange). Values all equal (low==high) fall in the middle.
- color(value, *, low=None, high=None)[source]¶
Get the color of
value, as #rrggbb; None for None, NaN or text.lowandhighare the range of a scale without its own (seerange).
- colors_of(values, *, low=None, high=None)[source]¶
Get the color of each value, as
colordoes: with NumPy for an array of numbers.
- table(count)[source]¶
Get
countcolors evenly spaced from the first to the last, e.g. for a lookup table.