bokeh.models.mappers

Models for mapping values from one range or space to another.

class CategoricalColorMapper(**kwargs)[source]

Bases: bokeh.models.mappers.ColorMapper

Map categories to colors. Values that are passed to this mapper that aren’t in factors will be assigned the nan_color.

factors

property type: Either ( Seq ( String ), Seq ( Int ), Seq ( Float ), Seq ( Datetime ), Seq ( Date ) )

A sequence of factors / categories that map to the color palette.

JSON Prototype
{
  "factors": null,
  "id": "38ce2421-0e1d-461a-ad82-a4ff1212504a",
  "js_callbacks": {},
  "name": null,
  "nan_color": "gray",
  "palette": null,
  "tags": []
}
class ColorMapper(palette=None, **kwargs)[source]

Bases: bokeh.model.Model

Base class for color mapper types. ColorMapper is not generally useful to instantiate on its own.

nan_color

property type: Color

Color to be used if data is NaN. Default: ‘gray’

palette

property type: Seq ( Color )

A sequence of colors to use as the target palette for mapping.

This property can also be set as a String, to the name of any of the palettes shown in bokeh.palettes.

JSON Prototype
{
  "id": "09c00c86-0f01-4b0c-aee2-17560cfdbbd1",
  "js_callbacks": {},
  "name": null,
  "nan_color": "gray",
  "palette": null,
  "tags": []
}
class ContinuousColorMapper(palette=None, **kwargs)[source]

Bases: bokeh.models.mappers.ColorMapper

Base class for cotinuous color mapper types. ContinuousColorMapper is not generally useful to instantiate on its own.

high

property type: Float

The maximum value of the range to map into the palette. Values above this are clamped to high.

high_color

property type: Color

Color to be used if data is lower than high value. If None, values lower than high are mapped to the last color in the palette.

low

property type: Float

The minimum value of the range to map into the palette. Values below this are clamped to low.

low_color

property type: Color

Color to be used if data is lower than low value. If None, values lower than low are mapped to the first color in the palette.

JSON Prototype
{
  "high": null,
  "high_color": null,
  "id": "e8bc9930-0f03-4548-a05c-3d7277977b4e",
  "js_callbacks": {},
  "low": null,
  "low_color": null,
  "name": null,
  "nan_color": "gray",
  "palette": null,
  "tags": []
}
class LinearColorMapper(palette=None, **kwargs)[source]

Bases: bokeh.models.mappers.ContinuousColorMapper

Map numbers in a range [low, high] linearly into a sequence of colors (a palette).

For example, if the range is [0, 99] and the palette is ['red', 'green', 'blue'], the values would be mapped as follows:

      x < 0  : 'red'     # values < low are clamped
 0 >= x < 33 : 'red'
33 >= x < 66 : 'green'
66 >= x < 99 : 'blue'
99 >= x      : 'blue'    # values > high are clamped
JSON Prototype
{
  "high": null,
  "high_color": null,
  "id": "1d1f13e6-d410-4875-95bb-60538cf685ac",
  "js_callbacks": {},
  "low": null,
  "low_color": null,
  "name": null,
  "nan_color": "gray",
  "palette": null,
  "tags": []
}
class LogColorMapper(palette=None, **kwargs)[source]

Bases: bokeh.models.mappers.ContinuousColorMapper

Map numbers in a range [low, high] into a sequence of colors (a palette) on a natural logarithm scale.

For example, if the range is [0, 25] and the palette is ['red', 'green', 'blue'], the values would be mapped as follows:

         x < 0     : 'red'     # values < low are clamped
0     >= x < 2.72  : 'red'     # math.e ** 1
2.72  >= x < 7.39  : 'green'   # math.e ** 2
7.39  >= x < 20.09 : 'blue'    # math.e ** 3
20.09 >= x         : 'blue'    # values > high are clamped

Warning

The LogColorMapper only works for images with scalar values that are non-negative.

JSON Prototype
{
  "high": null,
  "high_color": null,
  "id": "d808fef7-b312-44e8-9c5d-8b354002c049",
  "js_callbacks": {},
  "low": null,
  "low_color": null,
  "name": null,
  "nan_color": "gray",
  "palette": null,
  "tags": []
}