ptvis.color.DiscreteColorConversion

class ptvis.color.DiscreteColorConversion(colors=None, levels=None, value_min=None, value_max=None, lower_color=None, higher_color=None, na_color='#444444', n_intervals=10, closed='low', include_boundary=True)[source]

Bases: BaseNumericalColorConversion

Color conversion from numerical values to discrete colors.

Parameters:
  • colors (array-like of str, optional) – Colors defining a color scale.

  • levels (array-like of float, optional) – Levels defining a color scale. Must be in ascending order. If not given, evenly spaced levels are used.

  • value_min (float, optional) – Value corresponding with the lowest level.

  • value_max (float, optional) – Value corresponding with the highest level.

  • lower_color (str, optional) – Color for values lower than the domain.

  • higher_color (str, optional) – Color for values higher than the domain.

  • na_color (str, optional) – Color for NaN.

  • n_intervals (int, optional) – Number of intervals or discrete colors.

  • closed ({'low', 'high'}, optional) – Closed endpoint of an interval.

  • include_boundary (bool, optional) – If True, both boundaries are included in the domain.

Attributes

closed

Closed endpoint of an interval.

colors

Colors defining a color scale.

higher_color

Color for values higher than the domain.

include_boundary

Whether both boundaries are included in the domain.

levels

Levels defining a color scale.

lower_color

Color for values lower than the domain.

n_intervals

Number of intervals.

na_color

Color for NaN.

value_max

Value corresponding to the highest level.

value_min

Value corresponding to the lowest level.

Methods

apply(values)

Apply the conversion to values.

color_guide(values[, attrs])

Give a color guide.

domain(values)

Give a domain of the conversion.