Anaconda Enterprise: Documentation

# bokeh.models.mappers

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

class `bokeh.models.mappers.``CategoricalColorMapper`(**kwargs)

  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.

  `end`

    property type: `Int`

    A start index to “slice” data factors with before color mapping.

    For example, if the data to color map consists of 2-level factors such as `["2016", "sales"]` and `["2017", "marketing"]`, then setting `end=1` will perform color mapping only based on the first sub-factor (i.e. in this case based on the year `"2016"` or `"2017"`)

    If `None` then all sub-factors from `start` to the end of the factor will be used for color mapping.

  `factors`

    property type: `Either` ( `Seq` ( `String` ), `Seq` ( `Tuple` ( `String` , `String` ) ), `Seq` ( `Tuple` ( `String` , `String` , `String` ) ) )

    A sequence of factors / categories that map to the color palette. For example the following color mapper:

        mapper = CategoricalColorMapper(palette=["red", "blue"], factors=["foo", "bar"])

    will map the factor `"foo"` to red and the factor `"bar"` to blue.

  `start`

    property type: `Int`

    A start index to “slice” data factors with before color mapping.

    For example, if the data to color map consists of 2-level factors such as `["2016", "sales"]` and `["2016", "marketing"]`, then setting `start=1` will perform color mapping only based on the second sub-factor (i.e. in this case based on the department `"sales"` or `"marketing"`)

JSON Prototype

    {
      "end": null,
      "factors": null,
      "id": "c6652bfb-f2ab-4b46-b138-e86452522442",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "name": null,
      "nan_color": "gray",
      "palette": null,
      "start": 0,
      "subscribed_events": [],
      "tags": []
    }

class `bokeh.models.mappers.``ColorMapper`(palette=None, **kwargs)

  Bases: `bokeh.models.transforms.Transform`

  Base class for color mapper types.

  Note

  This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not 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": "9878ea20-bb09-46b6-bd13-3e33177a2256",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "name": null,
      "nan_color": "gray",
      "palette": null,
      "subscribed_events": [],
      "tags": []
    }

class `bokeh.models.mappers.``ContinuousColorMapper`(palette=None, **kwargs)

  Bases: `bokeh.models.mappers.ColorMapper`

  Base class for continuous color mapper types.

  Note

  This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not 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": "8cd3f853-472a-4021-b1b4-c52bbb920247",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "low": null,
      "low_color": null,
      "name": null,
      "nan_color": "gray",
      "palette": null,
      "subscribed_events": [],
      "tags": []
    }

class `bokeh.models.mappers.``LinearColorMapper`(palette=None, **kwargs)

  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": "5b554fbf-4b76-4db5-a41a-ae3a0aa3ec73",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "low": null,
      "low_color": null,
      "name": null,
      "nan_color": "gray",
      "palette": null,
      "subscribed_events": [],
      "tags": []
    }

class `bokeh.models.mappers.``LogColorMapper`(palette=None, **kwargs)

  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": "45dbc192-8b4a-4fe6-9c60-c9debba3cb63",
      "js_event_callbacks": {},
      "js_property_callbacks": {},
      "low": null,
      "low_color": null,
      "name": null,
      "nan_color": "gray",
      "palette": null,
      "subscribed_events": [],
      "tags": []
    }