mappers#
Models for mapping values from one range or space to another in the client.
Mappers (as opposed to scales) are not presumed to be invertible.
- class CategoricalColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Map categorical factors to colors.
Values that are passed to this mapper that are not in the factors list will be mapped to
nan_color.
- class CategoricalMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Base class for mappers that map categorical factors to other values.
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.
- end#
A start index to “slice” data factors with before mapping.
For example, if the data to color map consists of 2-level factors such as
["2016", "sales"]and["2017", "marketing"], then settingend=1will perform color mapping only based on the first sub-factor (i.e. in this case based on the year"2016"or"2017")If
Nonethen all sub-factors fromstartto the end of the factor will be used for color mapping.
- factors#
A sequence of factors / categories that map to the some target range. 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#
A start index to “slice” data factors with before mapping.
For example, if the data to color map consists of 2-level factors such as
["2016", "sales"]and["2016", "marketing"], then settingstart=1will perform color mapping only based on the second sub-factor (i.e. in this case based on the department"sales"or"marketing")
- class CategoricalMarkerMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Map categorical factors to marker types.
Values that are passed to this mapper that are not in the factors list will be mapped to
default_value.Note
This mappers is primarily only useful with the
Scattermarker glyph that be parameterized by marker type.- default_value#
A marker type to use in case an unrecognized factor is passed in to be mapped.
- markers#
A sequence of marker types to use as the target for mapping.
- class CategoricalPatternMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Map categorical factors to hatch fill patterns.
Values that are passed to this mapper that are not in the factors list will be mapped to
default_value.Added in version 1.1.1
- default_value#
A hatch pattern to use in case an unrecognized factor is passed in to be mapped.
- patterns#
A sequence of marker types to use as the target for mapping.
- class ColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
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#
Color to be used if data is NaN or otherwise not mappable.
Acceptable values are:
any of the named CSS colors, e.g
'green','indigo'RGB(A) hex strings, e.g.,
'#FF0000','#44444444'CSS4 color strings, e.g.,
'rgba(255, 0, 127, 0.6)','rgb(0 127 0 / 1.0)', or'hsl(60deg 100% 50% / 1.0)'a 3-tuple of integers (r, g, b) between 0 and 255
a 4-tuple of (r, g, b, a) where r, g, b are integers between 0 and 255, and a is between 0 and 1
a 32-bit unsigned integer using the 0xRRGGBBAA byte order pattern
- palette#
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.
- class ContinuousColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
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.
- domain#
A collection of glyph renderers to pool data from for establishing data metrics. If empty, mapped data will be used instead.
- high#
The maximum value of the range to map into the palette. Values above this are clamped to
high. IfNone, the value is inferred from data.
- high_color#
Color to be used if data is higher than
highvalue. If None, values higher thanhighare mapped to the last color in the palette.
- low#
The minimum value of the range to map into the palette. Values below this are clamped to
low. IfNone, the value is inferred from data.
- low_color#
Color to be used if data is lower than
lowvalue. If None, values lower thanloware mapped to the first color in the palette.
- class EqHistColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
- bins#
Number of histogram bins
- rescale_discrete_levels#
If there are only a few discrete levels in the values that are color mapped then
rescale_discrete_levels=Truedecreases the lower limit of the span so that the values are rendered towards the top end of the palette.
- class LinearColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
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
- class LogColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
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
LogColorMapperonly works for images with scalar values that are non-negative.
- class Mapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Base class for mappers.
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.
- class StackColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
- Abstract base class for color mappers that operate on
ImageStack glyphs.
These map 3D data arrays of shape
(ny, nx, nstack)to 2D RGBA images of shape(ny, nx).
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.
- Abstract base class for color mappers that operate on
- class WeightedStackColorMapper(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Maps 3D data arrays of shape
(ny, nx, nstack)to 2D RGBA images of shape(ny, nx)using a palette of lengthnstack.The mapping occurs in two stages. Firstly the RGB values are calculated using a weighted sum of the palette colors in the
nstackdirection. Then the alpha values are calculated using thealpha_mapperapplied to the sum of the array in thenstackdirection.The RGB values calculated by the
alpha_mapperare ignored by the color mapping but are used in anyColorBarthat is displayed.- alpha_mapper#
Color mapper used to calculate the alpha values of the mapped data.
- color_baseline#
Baseline value used for the weights when calculating the weighted sum of palette colors. If
Nonethen the minimum of the supplied data is used meaning that values at this minimum have a weight of zero and do not contribute to the weighted sum. As a special case, if all data for a particular output pixel are at the color baseline then the color is an evenly weighted average of the colors corresponding to all such values, to avoid the color being undefined.
- stack_labels#
An optional sequence of strings to use as labels for the
nstackstacks. If set, the number of labels should match the number of stacks and hence also the number of palette colors.The labels are used in hover tooltips for
ImageStackglyphs that use aWeightedStackColorMapperas their color mapper.