bokeh.transform¶
Helper functions for applying client-side computations such as
transformations to data fields or ColumnDataSource expressions.
-
dodge(field_name, value, range=None)[source]¶ Create a
DataSpecdict to apply a client-sideJittertransformation to aColumnDataSourcecolumn.Parameters: Returns: dict
-
factor_cmap(field_name, palette, factors, start=0, end=None, nan_color='gray')[source]¶ Create a
DataSpecdict to apply a client-sideCategoricalColorMappertransformation to aColumnDataSourcecolumn.Parameters: - field_name (str) – a field name to configure
DataSpecwith - palette (seq[color]) – a list of colors to use for colormapping
- factors (seq) – a sequences of categorical factors corresponding to the palette
- start (int, optional) – a start slice index to apply when the column data has factors with multiple levels. (default: 0)
- end (int, optional) – an end slice index to apply when the column data has factors with multiple levels. (default: None)
- nan_color (color, optional) – a default color to use when mapping data from a column does not succeed (default: “gray”)
Returns: dict
- field_name (str) – a field name to configure
-
jitter(field_name, width, mean=0, distribution='uniform', range=None)[source]¶ Create a
DataSpecdict to apply a client-sideJittertransformation to aColumnDataSourcecolumn.Parameters: - field_name (str) – a field name to configure
DataSpecwith - width (float) – the width of the random distribition to apply
- mean (float, optional) – an offset to apply (default: 0)
- distribution (str, optional) –
"uniform"or"normal"(default:"uniform") - range (Range, optional) – a range to use for computing synthetic
coordinates when necessary, e.g. a
FactorRangewhen the column data is categorical (default: None)
Returns: dict
- field_name (str) – a field name to configure
-
linear_cmap(field_name, palette, low, high, low_color=None, high_color=None, nan_color='gray')[source]¶ Create a
DataSpecdict to apply a client-sideLinearColorMappertransformation to aColumnDataSourcecolumn.Parameters: - field_name (str) – a field name to configure
DataSpecwith - palette (seq[color]) – a list of colors to use for colormapping
- low (float) – a minimum value of the range to map into the palette.
Values below this are clamped to
low. - high (float) – a maximum value of the range to map into the palette.
Values above this are clamped to
high. - low_color (color, optional) – color to be used if data is lower than
lowvalue. If None, values lower thanloware mapped to the first color in the palette. (default: None) - high_color (color, optional) – color to be used if data is higher than
highvalue. If None, values higher thanhighare mapped to the last color in the palette. (default: None) - nan_color (color, optional) – a default color to use when mapping data from a column does not succeed (default: “gray”)
- field_name (str) – a field name to configure
-
log_cmap(field_name, palette, low, high, low_color=None, high_color=None, nan_color='gray')[source]¶ Create a
DataSpecdict to apply a client-sideLogColorMappertransformation to aColumnDataSourcecolumn.Parameters: - field_name (str) – a field name to configure
DataSpecwith - palette (seq[color]) – a list of colors to use for colormapping
- low (float) – a minimum value of the range to map into the palette.
Values below this are clamped to
low. - high (float) – a maximum value of the range to map into the palette.
Values above this are clamped to
high. - low_color (color, optional) – color to be used if data is lower than
lowvalue. If None, values lower thanloware mapped to the first color in the palette. (default: None) - high_color (color, optional) – color to be used if data is higher than
highvalue. If None, values higher thanhighare mapped to the last color in the palette. (default: None) - nan_color (color, optional) – a default color to use when mapping data from a column does not succeed (default: “gray”)
- field_name (str) – a field name to configure
-
stack(*fields)[source]¶ Create a Create a
DataSpecdict to generate aStackexpression for aColumnDataSource.Examples
p.vbar(bottom=stack("sales", "marketing"), ...
will generate a
Stackthat sums the"sales"and"marketing"columns of a data source, and use those values as thetopcoordinate for aVBar.