annotations#

Renderers for various kinds of annotations that can be added to plots.

class Angular(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: CustomDimensional

Units of angular measurement.

JSON Prototype
{
  "basis": {
    "entries": [
      [
        "\u00b0", 
        [
          1, 
          "^\\circ", 
          "degree"
        ]
      ], 
      [
        "'", 
        [
          0.016666666666666666, 
          "^\\prime", 
          "minute"
        ]
      ], 
      [
        "''", 
        [
          0.0002777777777777778, 
          "^{\\prime\\prime}", 
          "second"
        ]
      ]
    ], 
    "type": "map"
  }, 
  "exclude": [], 
  "id": "p51720", 
  "include": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticks": [
    1, 
    3, 
    6, 
    12, 
    60, 
    120, 
    240, 
    360
  ]
}
basis = {'°': (1, '^\\circ', 'degree'), "'": (0.016666666666666666, '^\\prime', 'minute'), "''": (0.0002777777777777778, '^{\\prime\\prime}', 'second')}#
Type:

Required(Dict(String, Either(Tuple(Float, String), Tuple(Float, String, String))))

The basis defining the units of measurement.

This consists of a mapping between short unit names and their corresponding scaling factors, TeX names and optional long names. For example, the basis for defining angular units of measurement is:

basis = {
    "°":  (1,      "^\circ",           "degree"),
    "'":  (1/60,   "^\prime",          "minute"),
    "''": (1/3600, "^{\prime\prime}", "second"),
}
exclude = []#
Type:

List

A subset of units from the basis to avoid.

include = None#
Type:

Nullable(List)

An optional subset of preferred units from the basis.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticks = [1, 3, 6, 12, 60, 120, 240, 360]#
Type:

Required(List)

Preferred values to choose from in non-exact mode.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Annotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: CompositeRenderer

Base class for all annotation models.

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.

JSON Prototype
{
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p51728", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Arrow(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: DataAnnotation

Render arrows as an annotation.

See Arrows for information on plotting arrows.

JSON Prototype
{
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "end": {
    "id": "p51749", 
    "name": "OpenHead", 
    "type": "object"
  }, 
  "end_units": "data", 
  "group": null, 
  "id": "p51745", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "line_color": {
    "type": "value", 
    "value": "black"
  }, 
  "line_dash": {
    "type": "value", 
    "value": []
  }, 
  "line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "line_width": {
    "type": "value", 
    "value": 1
  }, 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "source": {
    "attributes": {
      "data": {
        "type": "map"
      }, 
      "selected": {
        "attributes": {
          "indices": [], 
          "line_indices": []
        }, 
        "id": "p51747", 
        "name": "Selection", 
        "type": "object"
      }, 
      "selection_policy": {
        "id": "p51748", 
        "name": "UnionRenderers", 
        "type": "object"
      }
    }, 
    "id": "p51746", 
    "name": "ColumnDataSource", 
    "type": "object"
  }, 
  "start": null, 
  "start_units": "data", 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "visible": true, 
  "x_end": {
    "field": "x_end", 
    "type": "field"
  }, 
  "x_range_name": "default", 
  "x_start": {
    "field": "x_start", 
    "type": "field"
  }, 
  "y_end": {
    "field": "y_end", 
    "type": "field"
  }, 
  "y_range_name": "default", 
  "y_start": {
    "field": "y_start", 
    "type": "field"
  }
}
context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

end = OpenHead(id='p51775', ...)#
Type:

Nullable(Instance(ArrowHead))

Instance of ArrowHead.

end_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the end_x and end_y attributes. Interpreted as “data space” units by default.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the arrow body.

line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the arrow body.

line_color = 'black'#
Type:

ColorSpec

The line color values for the arrow body.

line_dash = []#
Type:

DashPatternSpec

The line dash values for the arrow body.

line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the arrow body.

line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the arrow body.

line_width = 1#
Type:

NumberSpec

The line width values for the arrow body.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

source = ColumnDataSource(id='p51846', ...)#
Type:

Instance(DataSource)

Local data source to use when rendering annotations on the plot.

start = None#
Type:

Nullable(Instance(ArrowHead))

Instance of ArrowHead.

start_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the start_x and start_y attributes. Interpreted as “data space” units by default.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

visible = True#
Type:

Bool

Is the renderer visible.

x_end = Field(field='x_end', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The x-coordinates to locate the end of the arrows.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

x_start = Field(field='x_start', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The x-coordinates to locate the start of the arrows.

y_end = Field(field='y_end', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The y-coordinates to locate the end of the arrows.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

y_start = Field(field='y_start', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The y-coordinates to locate the start of the arrows.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ArrowHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Marking

Base class for arrow heads.

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.

JSON Prototype
{
  "id": "p51914", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "size": {
    "type": "value", 
    "value": 25
  }, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": []
}
name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

size = 25#
Type:

NumberSpec

The size, in pixels, of the arrow head.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Band(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: DataAnnotation

Render a filled area band along a dimension.

See Bands for information on plotting bands.

JSON Prototype
{
  "base": {
    "field": "base", 
    "type": "field"
  }, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "dimension": "height", 
  "elements": [], 
  "fill_alpha": 0.4, 
  "fill_color": "#fff9ba", 
  "group": null, 
  "id": "p51919", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "line_alpha": 0.3, 
  "line_cap": "butt", 
  "line_color": "#cccccc", 
  "line_dash": [], 
  "line_dash_offset": 0, 
  "line_join": "bevel", 
  "line_width": 1, 
  "lower": {
    "field": "lower", 
    "type": "field"
  }, 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "source": {
    "attributes": {
      "data": {
        "type": "map"
      }, 
      "selected": {
        "attributes": {
          "indices": [], 
          "line_indices": []
        }, 
        "id": "p51921", 
        "name": "Selection", 
        "type": "object"
      }, 
      "selection_policy": {
        "id": "p51922", 
        "name": "UnionRenderers", 
        "type": "object"
      }
    }, 
    "id": "p51920", 
    "name": "ColumnDataSource", 
    "type": "object"
  }, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "upper": {
    "field": "upper", 
    "type": "field"
  }, 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
base = Field(field='base', transform=Unspecified, units=Unspecified)#
Type:

UnitsSpec

The orthogonal coordinates of the upper and lower values.

base_units = 'data'#
Type:

NotSerialized(Enum(CoordinateUnits))

Units to use for the associated property: canvas, screen or data

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

dimension = 'height'#
Type:

Enum(Dimension)

The direction of the band can be specified by setting this property to “height” (y direction) or “width” (x direction).

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

fill_alpha = 0.4#
Type:

Alpha

The fill alpha values for the band.

fill_color = '#fff9ba'#
Type:

Nullable(Color)

The fill color values for the band.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

line_alpha = 0.3#
Type:

Alpha

The line alpha values for the band.

line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the band.

line_color = '#cccccc'#
Type:

Nullable(Color)

The line color values for the band.

line_dash = []#
Type:

DashPattern

The line dash values for the band.

line_dash_offset = 0#
Type:

Int

The line dash offset values for the band.

line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the band.

line_width = 1#
Type:

Float

The line width values for the band.

lower = Field(field='lower', transform=Unspecified, units=Unspecified)#
Type:

UnitsSpec

The coordinates of the lower portion of the filled area band.

lower_units = 'data'#
Type:

NotSerialized(Enum(CoordinateUnits))

Units to use for the associated property: canvas, screen or data

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

source = ColumnDataSource(id='p52019', ...)#
Type:

Instance(DataSource)

Local data source to use when rendering annotations on the plot.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

upper = Field(field='upper', transform=Unspecified, units=Unspecified)#
Type:

UnitsSpec

The coordinates of the upper portion of the filled area band.

upper_units = 'data'#
Type:

NotSerialized(Enum(CoordinateUnits))

Units to use for the associated property: canvas, screen or data

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class BoxAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation, AreaVisuals

Render a shaded rectangular region as an annotation.

See Box annotations for information on plotting box annotations.

JSON Prototype
{
  "border_radius": 0, 
  "bottom": {
    "attributes": {
      "symbol": "bottom", 
      "target": "frame"
    }, 
    "id": "p52062", 
    "name": "Node", 
    "type": "object"
  }, 
  "bottom_limit": null, 
  "bottom_units": "data", 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "editable": false, 
  "elements": [], 
  "fill_alpha": 0.4, 
  "fill_color": "#fff9ba", 
  "group": null, 
  "handles": {
    "attributes": {
      "all": {
        "attributes": {
          "fill_color": "white", 
          "hover_fill_color": "lightgray"
        }, 
        "id": "p52063", 
        "name": "AreaVisuals", 
        "type": "object"
      }
    }, 
    "id": "p52064", 
    "name": "BoxInteractionHandles", 
    "type": "object"
  }, 
  "hatch_alpha": 1.0, 
  "hatch_color": "black", 
  "hatch_extra": {
    "type": "map"
  }, 
  "hatch_pattern": null, 
  "hatch_scale": 12.0, 
  "hatch_weight": 1.0, 
  "hover_fill_alpha": 0.4, 
  "hover_fill_color": null, 
  "hover_hatch_alpha": 1.0, 
  "hover_hatch_color": "black", 
  "hover_hatch_extra": {
    "type": "map"
  }, 
  "hover_hatch_pattern": null, 
  "hover_hatch_scale": 12.0, 
  "hover_hatch_weight": 1.0, 
  "hover_line_alpha": 0.3, 
  "hover_line_cap": "butt", 
  "hover_line_color": null, 
  "hover_line_dash": [], 
  "hover_line_dash_offset": 0, 
  "hover_line_join": "bevel", 
  "hover_line_width": 1, 
  "id": "p52058", 
  "inverted": false, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "left": {
    "attributes": {
      "symbol": "left", 
      "target": "frame"
    }, 
    "id": "p52059", 
    "name": "Node", 
    "type": "object"
  }, 
  "left_limit": null, 
  "left_units": "data", 
  "level": "annotation", 
  "line_alpha": 0.3, 
  "line_cap": "butt", 
  "line_color": "#cccccc", 
  "line_dash": [], 
  "line_dash_offset": 0, 
  "line_join": "bevel", 
  "line_width": 1, 
  "max_height": {
    "type": "number", 
    "value": "+inf"
  }, 
  "max_width": {
    "type": "number", 
    "value": "+inf"
  }, 
  "min_height": 0, 
  "min_width": 0, 
  "movable": "both", 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "resizable": "all", 
  "right": {
    "attributes": {
      "symbol": "right", 
      "target": "frame"
    }, 
    "id": "p52060", 
    "name": "Node", 
    "type": "object"
  }, 
  "right_limit": null, 
  "right_units": "data", 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "symmetric": false, 
  "syncable": true, 
  "tags": [], 
  "top": {
    "attributes": {
      "symbol": "top", 
      "target": "frame"
    }, 
    "id": "p52061", 
    "name": "Node", 
    "type": "object"
  }, 
  "top_limit": null, 
  "top_units": "data", 
  "use_handles": false, 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
border_radius = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Allows the box to have rounded corners.

Note

This property is experimental and may change at any point.

bottom = Node(id='p52079', ...)#
Type:

Either(Either(Float, Datetime, Factor), Instance(Node))

The y-coordinates of the bottom edge of the box annotation.

bottom_limit = None#
Type:

Nullable(Either(Either(Float, Datetime, Factor), Instance(Node)))

Optional bottom limit for box movement.

Note

This property is experimental and may change at any point.

bottom_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the bottom attribute. Interpreted as data units by default. This doesn’t have any effect if bottom is a node.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

editable = False#
Type:

Bool

Allows to interactively modify the geometry of this box.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

fill_alpha = 0.4#
Type:

Alpha

The fill alpha values for the box.

fill_color = '#fff9ba'#
Type:

Nullable(Color)

The fill color values for the box.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

handles = BoxInteractionHandles(id='p52158', ...)#
Type:

Instance(BoxInteractionHandles)

Configure appearance of interaction handles.

Handles can be configured in bulk in an increasing level of specificity, were each level, if defined, overrides the more generic setting:

  • all -> move, resize

  • resize -> sides, corners

  • sides -> left, right, top, bottom

  • corners -> top_left, top_right, bottom_left, bottom_right

Note

This property is experimental and may change at any point.

hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the box.

hatch_color = 'black'#
Type:

Nullable(Color)

The hatch color values for the box.

hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the box.

hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the box.

hatch_scale = 12.0#
Type:

Size

The hatch scale values for the box.

hatch_weight = 1.0#
Type:

Size

The hatch weight values for the box.

hover_fill_alpha = 0.4#
Type:

Alpha

The fill alpha values for the box when hovering over.

hover_fill_color = None#
Type:

Nullable(Color)

The fill color values for the box when hovering over.

hover_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the box when hovering over.

hover_hatch_color = 'black'#
Type:

Nullable(Color)

The hatch color values for the box when hovering over.

hover_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the box when hovering over.

hover_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the box when hovering over.

hover_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the box when hovering over.

hover_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the box when hovering over.

hover_line_alpha = 0.3#
Type:

Alpha

The line alpha values for the box when hovering over.

hover_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the box when hovering over.

hover_line_color = None#
Type:

Nullable(Color)

The line color values for the box when hovering over.

hover_line_dash = []#
Type:

DashPattern

The line dash values for the box when hovering over.

hover_line_dash_offset = 0#
Type:

Int

The line dash offset values for the box when hovering over.

hover_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the box when hovering over.

hover_line_width = 1#
Type:

Float

The line width values for the box when hovering over.

inverted = False#
Type:

Bool

Inverts the geometry of the box, i.e. applies fill and hatch visuals to the outside of the box instead of the inside. Visuals are applied between the box and its parent, e.g. the frame.

left = Node(id='p52320', ...)#
Type:

Either(Either(Float, Datetime, Factor), Instance(Node))

The x-coordinates of the left edge of the box annotation.

left_limit = None#
Type:

Nullable(Either(Either(Float, Datetime, Factor), Instance(Node)))

Optional left limit for box movement.

Note

This property is experimental and may change at any point.

left_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the left attribute. Interpreted as data units by default. This doesn’t have any effect if left is a node.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

line_alpha = 0.3#
Type:

Alpha

The line alpha values for the box.

line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the box.

line_color = '#cccccc'#
Type:

Nullable(Color)

The line color values for the box.

line_dash = []#
Type:

DashPattern

The line dash values for the box.

line_dash_offset = 0#
Type:

Int

The line dash offset values for the box.

line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the box.

line_width = 1#
Type:

Float

The line width values for the box.

max_height = inf#
Type:

Positive

Allows to set the maximum height of the box.

Note

This property is experimental and may change at any point.

max_width = inf#
Type:

Positive

Allows to set the minium height of the box.

Note

This property is experimental and may change at any point.

min_height = 0#
Type:

NonNegative

Allows to set the maximum width of the box.

Note

This property is experimental and may change at any point.

min_width = 0#
Type:

NonNegative

Allows to set the minium width of the box.

Note

This property is experimental and may change at any point.

movable = 'both'#
Type:

Enum(Movable)

If editable is set, this property allows to configure in which directions the box can be moved.

Note

This property is experimental and may change at any point.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

resizable = 'all'#
Type:

Enum(Resizable)

If editable is set, this property allows to configure which combinations of edges are allowed to be moved, thus allows restrictions on resizing of the box.

Note

This property is experimental and may change at any point.

right = Node(id='p52461', ...)#
Type:

Either(Either(Float, Datetime, Factor), Instance(Node))

The x-coordinates of the right edge of the box annotation.

right_limit = None#
Type:

Nullable(Either(Either(Float, Datetime, Factor), Instance(Node)))

Optional right limit for box movement.

Note

This property is experimental and may change at any point.

right_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the right attribute. Interpreted as data units by default. This doesn’t have any effect if right is a node.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

symmetric = False#
Type:

Bool

Indicates whether the box is resizable around its center or its corners.

Note

This property is experimental and may change at any point.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

top = Node(id='p52518', ...)#
Type:

Either(Either(Float, Datetime, Factor), Instance(Node))

The y-coordinates of the top edge of the box annotation.

top_limit = None#
Type:

Nullable(Either(Either(Float, Datetime, Factor), Instance(Node)))

Optional top limit for box movement.

Note

This property is experimental and may change at any point.

top_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the top attribute. Interpreted as data units by default. This doesn’t have any effect if top is a node.

use_handles = False#
Type:

Bool

Whether to show interaction (move, resize, etc.) handles.

If handles aren’t used, then the whole annotation, its borders and corners act as if they were interaction handles.

Note

This property is experimental and may change at any point.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class BoxInteractionHandles(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Model

Defines interaction handles for box-like annotations.

JSON Prototype
{
  "all": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "bottom": null, 
  "bottom_left": null, 
  "bottom_right": null, 
  "corners": null, 
  "id": "p52561", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "left": null, 
  "move": null, 
  "name": null, 
  "resize": null, 
  "right": null, 
  "sides": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "top": null, 
  "top_left": null, 
  "top_right": null
}
name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ColorBar(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: BaseColorBar

Render a color bar based on a color mapper.

See Color bars for information on plotting color bars.

JSON Prototype
{
  "background_fill_alpha": 0.95, 
  "background_fill_color": "#ffffff", 
  "bar_line_alpha": 1.0, 
  "bar_line_cap": "butt", 
  "bar_line_color": null, 
  "bar_line_dash": [], 
  "bar_line_dash_offset": 0, 
  "bar_line_join": "bevel", 
  "bar_line_width": 1, 
  "border_line_alpha": 1.0, 
  "border_line_cap": "butt", 
  "border_line_color": null, 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "color_mapper": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "display_high": null, 
  "display_low": null, 
  "elements": [], 
  "formatter": "auto", 
  "group": null, 
  "height": "auto", 
  "id": "p52565", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "label_standoff": 5, 
  "level": "annotation", 
  "location": "top_right", 
  "major_label_overrides": {
    "type": "map"
  }, 
  "major_label_policy": {
    "id": "p52566", 
    "name": "NoOverlap", 
    "type": "object"
  }, 
  "major_label_text_align": "left", 
  "major_label_text_alpha": 1.0, 
  "major_label_text_baseline": "bottom", 
  "major_label_text_color": "#444444", 
  "major_label_text_font": "helvetica", 
  "major_label_text_font_size": "11px", 
  "major_label_text_font_style": "normal", 
  "major_label_text_line_height": 1.2, 
  "major_label_text_outline_color": null, 
  "major_tick_in": 5, 
  "major_tick_line_alpha": 1.0, 
  "major_tick_line_cap": "butt", 
  "major_tick_line_color": "#ffffff", 
  "major_tick_line_dash": [], 
  "major_tick_line_dash_offset": 0, 
  "major_tick_line_join": "bevel", 
  "major_tick_line_width": 1, 
  "major_tick_out": 0, 
  "margin": 30, 
  "minor_tick_in": 0, 
  "minor_tick_line_alpha": 1.0, 
  "minor_tick_line_cap": "butt", 
  "minor_tick_line_color": null, 
  "minor_tick_line_dash": [], 
  "minor_tick_line_dash_offset": 0, 
  "minor_tick_line_join": "bevel", 
  "minor_tick_line_width": 1, 
  "minor_tick_out": 0, 
  "name": null, 
  "orientation": "auto", 
  "padding": 10, 
  "propagate_hover": false, 
  "renderers": [], 
  "scale_alpha": 1.0, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticker": "auto", 
  "title": null, 
  "title_standoff": 2, 
  "title_text_align": "left", 
  "title_text_alpha": 1.0, 
  "title_text_baseline": "bottom", 
  "title_text_color": "#444444", 
  "title_text_font": "helvetica", 
  "title_text_font_size": "13px", 
  "title_text_font_style": "italic", 
  "title_text_line_height": 1.2, 
  "title_text_outline_color": null, 
  "visible": true, 
  "width": "auto", 
  "x_range_name": "default", 
  "y_range_name": "default"
}
background_fill_alpha = 0.95#
Type:

Alpha

The fill alpha for the color bar background style.

background_fill_color = '#ffffff'#
Type:

Nullable(Color)

The fill color for the color bar background style.

bar_line_alpha = 1.0#
Type:

Alpha

The line alpha for the color scale bar outline.

bar_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap for the color scale bar outline.

bar_line_color = None#
Type:

Nullable(Color)

The line color for the color scale bar outline.

bar_line_dash = []#
Type:

DashPattern

The line dash for the color scale bar outline.

bar_line_dash_offset = 0#
Type:

Int

The line dash offset for the color scale bar outline.

bar_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join for the color scale bar outline.

bar_line_width = 1#
Type:

Float

The line width for the color scale bar outline.

border_line_alpha = 1.0#
Type:

Alpha

The line alpha for the color bar border outline.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap for the color bar border outline.

border_line_color = None#
Type:

Nullable(Color)

The line color for the color bar border outline.

border_line_dash = []#
Type:

DashPattern

The line dash for the color bar border outline.

border_line_dash_offset = 0#
Type:

Int

The line dash offset for the color bar border outline.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join for the color bar border outline.

border_line_width = 1#
Type:

Float

The line width for the color bar border outline.

color_mapper = Undefined#
Type:

Instance(ColorMapper)

A color mapper containing a color palette to render.

Warning

If the low and high attributes of the ColorMapper aren’t set, ticks and tick labels won’t be rendered. Additionally, if a LogTicker is passed to the ticker argument and either or both of the logarithms of low and high values of the color_mapper are non-numeric (i.e. low=0), the tick and tick labels won’t be rendered.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

display_high = None#
Type:

Nullable(Float)

The highest value to display in the color bar. The whole of the color entry containing this value is shown.

display_low = None#
Type:

Nullable(Float)

The lowest value to display in the color bar. The whole of the color entry containing this value is shown.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

formatter = 'auto'#
Type:

Either(Instance(TickFormatter), Auto)

A TickFormatter to use for formatting the visual appearance of ticks.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

height = 'auto'#
Type:

Either(Auto, Int)

The height (in pixels) that the color scale should occupy.

label_standoff = 5#
Type:

Int

The distance (in pixels) to separate the tick labels from the color bar.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

location = 'top_right'#
Type:

Either(Enum(Anchor), Tuple(Float, Float))

The location where the color bar should draw itself. It’s either one of bokeh.core.enums.Anchor’s enumerated values, or a (x, y) tuple indicating an absolute location absolute location in screen coordinates (pixels from the bottom-left corner).

Warning

If the color bar is placed in a side panel, the location will likely have to be set to (0,0).

major_label_overrides = {}#
Type:

Dict(Either(Float, String), TextLike)

Provide explicit tick label values for specific tick locations that override normal formatting.

major_label_policy = NoOverlap(id='p52629', ...)#
Type:

Instance(LabelingPolicy)

Allows to filter out labels, e.g. declutter labels to avoid overlap.

major_label_text_align = 'left'#
Type:

Enum(TextAlign)

The text align of the major tick labels.

major_label_text_alpha = 1.0#
Type:

Alpha

The text alpha of the major tick labels.

major_label_text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline of the major tick labels.

major_label_text_color = '#444444'#
Type:

Nullable(Color)

The text color of the major tick labels.

major_label_text_font = 'helvetica'#
Type:

String

The text font of the major tick labels.

major_label_text_font_size = '11px'#
Type:

FontSize

The text font size of the major tick labels.

major_label_text_font_style = 'normal'#
Type:

Enum(FontStyle)

The text font style of the major tick labels.

major_label_text_line_height = 1.2#
Type:

Float

The text line height of the major tick labels.

major_label_text_outline_color = None#
Type:

Nullable(Color)

The text outline color of the major tick labels.

major_tick_in = 5#
Type:

Int

The distance (in pixels) that major ticks should extend into the main plot area.

major_tick_line_alpha = 1.0#
Type:

Alpha

The line alpha of the major ticks.

major_tick_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap of the major ticks.

major_tick_line_color = '#ffffff'#
Type:

Nullable(Color)

The line color of the major ticks.

major_tick_line_dash = []#
Type:

DashPattern

The line dash of the major ticks.

major_tick_line_dash_offset = 0#
Type:

Int

The line dash offset of the major ticks.

major_tick_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join of the major ticks.

major_tick_line_width = 1#
Type:

Float

The line width of the major ticks.

major_tick_out = 0#
Type:

Int

The distance (in pixels) that major ticks should extend out of the main plot area.

margin = 30#
Type:

Int

Amount of margin (in pixels) around the outside of the color bar.

minor_tick_in = 0#
Type:

Int

The distance (in pixels) that minor ticks should extend into the main plot area.

minor_tick_line_alpha = 1.0#
Type:

Alpha

The line alpha of the minor ticks.

minor_tick_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap of the minor ticks.

minor_tick_line_color = None#
Type:

Nullable(Color)

The line color of the minor ticks.

minor_tick_line_dash = []#
Type:

DashPattern

The line dash of the minor ticks.

minor_tick_line_dash_offset = 0#
Type:

Int

The line dash offset of the minor ticks.

minor_tick_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join of the minor ticks.

minor_tick_line_width = 1#
Type:

Float

The line width of the minor ticks.

minor_tick_out = 0#
Type:

Int

The distance (in pixels) that major ticks should extend out of the main plot area.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

orientation = 'auto'#
Type:

Either(Enum(Orientation), Auto)

Whether the color bar should be oriented vertically or horizontally.

padding = 10#
Type:

Int

Amount of padding (in pixels) between the color scale and color bar border.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

scale_alpha = 1.0#
Type:

Float

The alpha with which to render the color scale.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticker = 'auto'#
Type:

Either(Instance(Ticker), Auto)

A Ticker to use for computing locations of axis components.

title = None#
Type:

Nullable(TextLike)

The title text to render.

title_standoff = 2#
Type:

Int

The distance (in pixels) to separate the title from the color bar.

title_text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the title text.

title_text_alpha = 1.0#
Type:

Alpha

The text alpha values for the title text.

title_text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the title text.

title_text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the title text.

title_text_font = 'helvetica'#
Type:

String

The text font values for the title text.

title_text_font_size = '13px'#
Type:

FontSize

The text font size values for the title text.

title_text_font_style = 'italic'#
Type:

Enum(FontStyle)

The text font style values for the title text.

title_text_line_height = 1.2#
Type:

Float

The text line height values for the title text.

title_text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the title text.

visible = True#
Type:

Bool

Is the renderer visible.

width = 'auto'#
Type:

Either(Auto, Int)

The width (in pixels) that the color scale should occupy.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ContourColorBar(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: BaseColorBar

Color bar used for contours.

Supports displaying hatch patterns and line styles that contour plots may have as well as the usual fill styles.

Do not create these objects manually, instead use ContourRenderer.color_bar.

JSON Prototype
{
  "background_fill_alpha": 0.95, 
  "background_fill_color": "#ffffff", 
  "bar_line_alpha": 1.0, 
  "bar_line_cap": "butt", 
  "bar_line_color": null, 
  "bar_line_dash": [], 
  "bar_line_dash_offset": 0, 
  "bar_line_join": "bevel", 
  "bar_line_width": 1, 
  "border_line_alpha": 1.0, 
  "border_line_cap": "butt", 
  "border_line_color": null, 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "fill_renderer": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "formatter": "auto", 
  "group": null, 
  "height": "auto", 
  "id": "p52738", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "label_standoff": 5, 
  "level": "annotation", 
  "levels": [], 
  "line_renderer": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "location": "top_right", 
  "major_label_overrides": {
    "type": "map"
  }, 
  "major_label_policy": {
    "id": "p52739", 
    "name": "NoOverlap", 
    "type": "object"
  }, 
  "major_label_text_align": "left", 
  "major_label_text_alpha": 1.0, 
  "major_label_text_baseline": "bottom", 
  "major_label_text_color": "#444444", 
  "major_label_text_font": "helvetica", 
  "major_label_text_font_size": "11px", 
  "major_label_text_font_style": "normal", 
  "major_label_text_line_height": 1.2, 
  "major_label_text_outline_color": null, 
  "major_tick_in": 5, 
  "major_tick_line_alpha": 1.0, 
  "major_tick_line_cap": "butt", 
  "major_tick_line_color": "#ffffff", 
  "major_tick_line_dash": [], 
  "major_tick_line_dash_offset": 0, 
  "major_tick_line_join": "bevel", 
  "major_tick_line_width": 1, 
  "major_tick_out": 0, 
  "margin": 30, 
  "minor_tick_in": 0, 
  "minor_tick_line_alpha": 1.0, 
  "minor_tick_line_cap": "butt", 
  "minor_tick_line_color": null, 
  "minor_tick_line_dash": [], 
  "minor_tick_line_dash_offset": 0, 
  "minor_tick_line_join": "bevel", 
  "minor_tick_line_width": 1, 
  "minor_tick_out": 0, 
  "name": null, 
  "orientation": "auto", 
  "padding": 10, 
  "propagate_hover": false, 
  "renderers": [], 
  "scale_alpha": 1.0, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticker": "auto", 
  "title": null, 
  "title_standoff": 2, 
  "title_text_align": "left", 
  "title_text_alpha": 1.0, 
  "title_text_baseline": "bottom", 
  "title_text_color": "#444444", 
  "title_text_font": "helvetica", 
  "title_text_font_size": "13px", 
  "title_text_font_style": "italic", 
  "title_text_line_height": 1.2, 
  "title_text_outline_color": null, 
  "visible": true, 
  "width": "auto", 
  "x_range_name": "default", 
  "y_range_name": "default"
}
background_fill_alpha = 0.95#
Type:

Alpha

The fill alpha for the color bar background style.

background_fill_color = '#ffffff'#
Type:

Nullable(Color)

The fill color for the color bar background style.

bar_line_alpha = 1.0#
Type:

Alpha

The line alpha for the color scale bar outline.

bar_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap for the color scale bar outline.

bar_line_color = None#
Type:

Nullable(Color)

The line color for the color scale bar outline.

bar_line_dash = []#
Type:

DashPattern

The line dash for the color scale bar outline.

bar_line_dash_offset = 0#
Type:

Int

The line dash offset for the color scale bar outline.

bar_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join for the color scale bar outline.

bar_line_width = 1#
Type:

Float

The line width for the color scale bar outline.

border_line_alpha = 1.0#
Type:

Alpha

The line alpha for the color bar border outline.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap for the color bar border outline.

border_line_color = None#
Type:

Nullable(Color)

The line color for the color bar border outline.

border_line_dash = []#
Type:

DashPattern

The line dash for the color bar border outline.

border_line_dash_offset = 0#
Type:

Int

The line dash offset for the color bar border outline.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join for the color bar border outline.

border_line_width = 1#
Type:

Float

The line width for the color bar border outline.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

fill_renderer = Undefined#
Type:

Instance(GlyphRenderer)

Glyph renderer used for filled contour polygons.

formatter = 'auto'#
Type:

Either(Instance(TickFormatter), Auto)

A TickFormatter to use for formatting the visual appearance of ticks.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

height = 'auto'#
Type:

Either(Auto, Int)

The height (in pixels) that the color scale should occupy.

label_standoff = 5#
Type:

Int

The distance (in pixels) to separate the tick labels from the color bar.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

levels = []#
Type:

Seq(Float)

Levels at which the contours are calculated.

line_renderer = Undefined#
Type:

Instance(GlyphRenderer)

Glyph renderer used for contour lines.

location = 'top_right'#
Type:

Either(Enum(Anchor), Tuple(Float, Float))

The location where the color bar should draw itself. It’s either one of bokeh.core.enums.Anchor’s enumerated values, or a (x, y) tuple indicating an absolute location absolute location in screen coordinates (pixels from the bottom-left corner).

Warning

If the color bar is placed in a side panel, the location will likely have to be set to (0,0).

major_label_overrides = {}#
Type:

Dict(Either(Float, String), TextLike)

Provide explicit tick label values for specific tick locations that override normal formatting.

major_label_policy = NoOverlap(id='p52802', ...)#
Type:

Instance(LabelingPolicy)

Allows to filter out labels, e.g. declutter labels to avoid overlap.

major_label_text_align = 'left'#
Type:

Enum(TextAlign)

The text align of the major tick labels.

major_label_text_alpha = 1.0#
Type:

Alpha

The text alpha of the major tick labels.

major_label_text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline of the major tick labels.

major_label_text_color = '#444444'#
Type:

Nullable(Color)

The text color of the major tick labels.

major_label_text_font = 'helvetica'#
Type:

String

The text font of the major tick labels.

major_label_text_font_size = '11px'#
Type:

FontSize

The text font size of the major tick labels.

major_label_text_font_style = 'normal'#
Type:

Enum(FontStyle)

The text font style of the major tick labels.

major_label_text_line_height = 1.2#
Type:

Float

The text line height of the major tick labels.

major_label_text_outline_color = None#
Type:

Nullable(Color)

The text outline color of the major tick labels.

major_tick_in = 5#
Type:

Int

The distance (in pixels) that major ticks should extend into the main plot area.

major_tick_line_alpha = 1.0#
Type:

Alpha

The line alpha of the major ticks.

major_tick_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap of the major ticks.

major_tick_line_color = '#ffffff'#
Type:

Nullable(Color)

The line color of the major ticks.

major_tick_line_dash = []#
Type:

DashPattern

The line dash of the major ticks.

major_tick_line_dash_offset = 0#
Type:

Int

The line dash offset of the major ticks.

major_tick_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join of the major ticks.

major_tick_line_width = 1#
Type:

Float

The line width of the major ticks.

major_tick_out = 0#
Type:

Int

The distance (in pixels) that major ticks should extend out of the main plot area.

margin = 30#
Type:

Int

Amount of margin (in pixels) around the outside of the color bar.

minor_tick_in = 0#
Type:

Int

The distance (in pixels) that minor ticks should extend into the main plot area.

minor_tick_line_alpha = 1.0#
Type:

Alpha

The line alpha of the minor ticks.

minor_tick_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap of the minor ticks.

minor_tick_line_color = None#
Type:

Nullable(Color)

The line color of the minor ticks.

minor_tick_line_dash = []#
Type:

DashPattern

The line dash of the minor ticks.

minor_tick_line_dash_offset = 0#
Type:

Int

The line dash offset of the minor ticks.

minor_tick_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join of the minor ticks.

minor_tick_line_width = 1#
Type:

Float

The line width of the minor ticks.

minor_tick_out = 0#
Type:

Int

The distance (in pixels) that major ticks should extend out of the main plot area.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

orientation = 'auto'#
Type:

Either(Enum(Orientation), Auto)

Whether the color bar should be oriented vertically or horizontally.

padding = 10#
Type:

Int

Amount of padding (in pixels) between the color scale and color bar border.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

scale_alpha = 1.0#
Type:

Float

The alpha with which to render the color scale.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticker = 'auto'#
Type:

Either(Instance(Ticker), Auto)

A Ticker to use for computing locations of axis components.

title = None#
Type:

Nullable(TextLike)

The title text to render.

title_standoff = 2#
Type:

Int

The distance (in pixels) to separate the title from the color bar.

title_text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the title text.

title_text_alpha = 1.0#
Type:

Alpha

The text alpha values for the title text.

title_text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the title text.

title_text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the title text.

title_text_font = 'helvetica'#
Type:

String

The text font values for the title text.

title_text_font_size = '13px'#
Type:

FontSize

The text font size values for the title text.

title_text_font_style = 'italic'#
Type:

Enum(FontStyle)

The text font style values for the title text.

title_text_line_height = 1.2#
Type:

Float

The text line height values for the title text.

title_text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the title text.

visible = True#
Type:

Bool

Is the renderer visible.

width = 'auto'#
Type:

Either(Auto, Int)

The width (in pixels) that the color scale should occupy.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class HTMLAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation

Base class for HTML-based annotations.

Note

All annotations that inherit from this base class can be attached to a canvas, but are not rendered to it, thus they won’t appear in saved plots. Only export_png() function can preserve HTML annotations.

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.

JSON Prototype
{
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p52911", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class HTMLLabel(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLTextAnnotation

Render a single HTML label as an annotation.

Label will render a single text label at given x and y coordinates, which can be in either screen (pixel) space, or data (axis range) space.

The label can also be configured with a screen space offset from x and y, by using the x_offset and y_offset properties.

Additionally, the label can be rotated with the angle property.

There are also standard text, fill, and line properties to control the appearance of the text, its background, as well as the rectangular bounding box border.

See Labels for information on plotting labels.

JSON Prototype
{
  "angle": 0, 
  "angle_units": "rad", 
  "background_fill_alpha": 1.0, 
  "background_fill_color": null, 
  "background_hatch_alpha": 1.0, 
  "background_hatch_color": null, 
  "background_hatch_extra": {
    "type": "map"
  }, 
  "background_hatch_pattern": null, 
  "background_hatch_scale": 12.0, 
  "background_hatch_weight": 1.0, 
  "border_line_alpha": 1.0, 
  "border_line_cap": "butt", 
  "border_line_color": null, 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "border_radius": 0, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p52928", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "padding": 0, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "text": "", 
  "text_align": "left", 
  "text_alpha": 1.0, 
  "text_baseline": "bottom", 
  "text_color": "#444444", 
  "text_font": "helvetica", 
  "text_font_size": "16px", 
  "text_font_style": "normal", 
  "text_line_height": 1.2, 
  "text_outline_color": null, 
  "visible": true, 
  "x": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "x_offset": 0, 
  "x_range_name": "default", 
  "x_units": "data", 
  "y": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "y_offset": 0, 
  "y_range_name": "default", 
  "y_units": "data"
}
angle = 0#
Type:

Angle

The angle to rotate the text, as measured from the horizontal.

angle_units = 'rad'#
Type:

Enum(AngleUnits)

Acceptable values for units are "rad" and "deg"

background_fill_alpha = 1.0#
Type:

Alpha

The fill alpha values for the text bounding box.

background_fill_color = None#
Type:

Nullable(Color)

The fill color values for the text bounding box.

background_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the text bounding box.

background_hatch_color = None#
Type:

Nullable(Color)

The hatch color values for the text bounding box.

background_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the text bounding box.

background_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the text bounding box.

background_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the text bounding box.

background_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the text bounding box.

border_line_alpha = 1.0#
Type:

Alpha

The line alpha values for the text bounding box.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the text bounding box.

border_line_color = None#
Type:

Nullable(Color)

The line color values for the text bounding box.

border_line_dash = []#
Type:

DashPattern

The line dash values for the text bounding box.

border_line_dash_offset = 0#
Type:

Int

The line dash offset values for the text bounding box.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the text bounding box.

border_line_width = 1#
Type:

Float

The line width values for the text bounding box.

border_radius = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Allows label’s box to have rounded corners. For the best results, it should be used in combination with padding.

Note

This property is experimental and may change at any point.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

padding = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative), Struct, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Extra space between the text of a label and its bounding box (border).

Note

This property is experimental and may change at any point.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text = ''#
Type:

String

The text value to render.

text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the text.

text_alpha = 1.0#
Type:

Alpha

The text alpha values for the text.

text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the text.

text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the text.

text_font = 'helvetica'#
Type:

String

The text font values for the text.

text_font_size = '16px'#
Type:

FontSize

The text font size values for the text.

text_font_style = 'normal'#
Type:

Enum(FontStyle)

The text font style values for the text.

text_line_height = 1.2#
Type:

Float

The text line height values for the text.

text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the text.

visible = True#
Type:

Bool

Is the renderer visible.

x = Undefined#
Type:

Required(Either(Float, Datetime, Factor))

The x-coordinate in screen coordinates to locate the text anchors.

x_offset = 0#
Type:

Float

Offset value to apply to the x-coordinate.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

x_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the x attribute. Interpreted as data units by default.

y = Undefined#
Type:

Required(Either(Float, Datetime, Factor))

The y-coordinate in screen coordinates to locate the text anchors.

y_offset = 0#
Type:

Float

Offset value to apply to the y-coordinate.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

y_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the y attribute. Interpreted as data units by default.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class HTMLLabelSet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLAnnotation, DataAnnotation

Render multiple text labels as annotations.

LabelSet will render multiple text labels at given x and y coordinates, which can be in either screen (pixel) space, or data (axis range) space. In this case (as opposed to the single Label model), x and y can also be the name of a column from a ColumnDataSource, in which case the labels will be “vectorized” using coordinate values from the specified columns.

The label can also be configured with a screen space offset from x and y, by using the x_offset and y_offset properties. These offsets may be vectorized by giving the name of a data source column.

Additionally, the label can be rotated with the angle property (which may also be a column name.)

There are also standard text, fill, and line properties to control the appearance of the text, its background, as well as the rectangular bounding box border.

The data source is provided by setting the source property.

JSON Prototype
{
  "angle": {
    "type": "value", 
    "value": 0
  }, 
  "background_fill_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "background_fill_color": {
    "type": "value", 
    "value": null
  }, 
  "border_line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "border_line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "border_line_color": {
    "type": "value", 
    "value": null
  }, 
  "border_line_dash": {
    "type": "value", 
    "value": []
  }, 
  "border_line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "border_line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "border_line_width": {
    "type": "value", 
    "value": 1
  }, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p52980", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "source": {
    "attributes": {
      "data": {
        "type": "map"
      }, 
      "selected": {
        "attributes": {
          "indices": [], 
          "line_indices": []
        }, 
        "id": "p52982", 
        "name": "Selection", 
        "type": "object"
      }, 
      "selection_policy": {
        "id": "p52983", 
        "name": "UnionRenderers", 
        "type": "object"
      }
    }, 
    "id": "p52981", 
    "name": "ColumnDataSource", 
    "type": "object"
  }, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "text": {
    "field": "text", 
    "type": "field"
  }, 
  "text_align": {
    "type": "value", 
    "value": "left"
  }, 
  "text_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "text_baseline": {
    "type": "value", 
    "value": "bottom"
  }, 
  "text_color": {
    "type": "value", 
    "value": "#444444"
  }, 
  "text_font": {
    "type": "value", 
    "value": "helvetica"
  }, 
  "text_font_size": {
    "type": "value", 
    "value": "16px"
  }, 
  "text_font_style": {
    "type": "value", 
    "value": "normal"
  }, 
  "text_line_height": {
    "type": "value", 
    "value": 1.2
  }, 
  "text_outline_color": {
    "type": "value", 
    "value": null
  }, 
  "visible": true, 
  "x": {
    "field": "x", 
    "type": "field"
  }, 
  "x_offset": {
    "type": "value", 
    "value": 0
  }, 
  "x_range_name": "default", 
  "x_units": "data", 
  "y": {
    "field": "y", 
    "type": "field"
  }, 
  "y_offset": {
    "type": "value", 
    "value": 0
  }, 
  "y_range_name": "default", 
  "y_units": "data"
}
angle = 0#
Type:

AngleSpec

The angles to rotate the text, as measured from the horizontal.

angle_units = 'rad'#
Type:

NotSerialized(Enum(AngleUnits))

Units to use for the associated property: deg, rad, grad or turn

background_fill_alpha = 1.0#
Type:

AlphaSpec

The fill alpha values for the text bounding box.

background_fill_color = None#
Type:

ColorSpec

The fill color values for the text bounding box.

border_line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the text bounding box.

border_line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the text bounding box.

border_line_color = None#
Type:

ColorSpec

The line color values for the text bounding box.

border_line_dash = []#
Type:

DashPatternSpec

The line dash values for the text bounding box.

border_line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the text bounding box.

border_line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the text bounding box.

border_line_width = 1#
Type:

NumberSpec

The line width values for the text bounding box.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

source = ColumnDataSource(id='p53068', ...)#
Type:

Instance(DataSource)

Local data source to use when rendering annotations on the plot.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text = Field(field='text', transform=Unspecified, units=Unspecified)#
Type:

NullStringSpec

The text values to render.

text_align = 'left'#
Type:

TextAlignSpec

The text align values for the text.

text_alpha = 1.0#
Type:

AlphaSpec

The text alpha values for the text.

text_baseline = 'bottom'#
Type:

TextBaselineSpec

The text baseline values for the text.

text_color = '#444444'#
Type:

ColorSpec

The text color values for the text.

text_font = Value(value='helvetica', transform=Unspecified, units=Unspecified)#
Type:

StringSpec

The text font values for the text.

text_font_size = Value(value='16px', transform=Unspecified, units=Unspecified)#
Type:

FontSizeSpec

The text font size values for the text.

text_font_style = 'normal'#
Type:

FontStyleSpec

The text font style values for the text.

text_line_height = 1.2#
Type:

NumberSpec

The text line height values for the text.

text_outline_color = None#
Type:

ColorSpec

The text outline color values for the text.

visible = True#
Type:

Bool

Is the renderer visible.

x = Field(field='x', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The x-coordinates to locate the text anchors.

x_offset = 0#
Type:

NumberSpec

Offset values to apply to the x-coordinates.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

x_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the xs attribute. Interpreted as data units by default.

y = Field(field='y', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The y-coordinates to locate the text anchors.

y_offset = 0#
Type:

NumberSpec

Offset values to apply to the y-coordinates.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

y_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the ys attribute. Interpreted as data units by default.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class HTMLTitle(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLTextAnnotation

Render a single title box as an annotation.

See Titles for information on plotting titles.

JSON Prototype
{
  "align": "left", 
  "background_fill_alpha": 1.0, 
  "background_fill_color": null, 
  "background_hatch_alpha": 1.0, 
  "background_hatch_color": null, 
  "background_hatch_extra": {
    "type": "map"
  }, 
  "background_hatch_pattern": null, 
  "background_hatch_scale": 12.0, 
  "background_hatch_weight": 1.0, 
  "border_line_alpha": 1.0, 
  "border_line_cap": "butt", 
  "border_line_color": null, 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "border_radius": 0, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p53163", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "offset": 0, 
  "padding": 0, 
  "propagate_hover": false, 
  "renderers": [], 
  "standoff": 10, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "text": "", 
  "text_alpha": 1.0, 
  "text_color": "#444444", 
  "text_font": "helvetica", 
  "text_font_size": "13px", 
  "text_font_style": "bold", 
  "text_line_height": 1.0, 
  "text_outline_color": null, 
  "vertical_align": "bottom", 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
align = 'left'#
Type:

Enum(TextAlign)

Alignment of the text in its enclosing space, along the direction of the text.

background_fill_alpha = 1.0#
Type:

Alpha

The fill alpha values for the text bounding box.

background_fill_color = None#
Type:

Nullable(Color)

The fill color values for the text bounding box.

background_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the text bounding box.

background_hatch_color = None#
Type:

Nullable(Color)

The hatch color values for the text bounding box.

background_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the text bounding box.

background_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the text bounding box.

background_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the text bounding box.

background_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the text bounding box.

border_line_alpha = 1.0#
Type:

Alpha

The line alpha values for the text bounding box.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the text bounding box.

border_line_color = None#
Type:

Nullable(Color)

The line color values for the text bounding box.

border_line_dash = []#
Type:

DashPattern

The line dash values for the text bounding box.

border_line_dash_offset = 0#
Type:

Int

The line dash offset values for the text bounding box.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the text bounding box.

border_line_width = 1#
Type:

Float

The line width values for the text bounding box.

border_radius = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Allows label’s box to have rounded corners. For the best results, it should be used in combination with padding.

Note

This property is experimental and may change at any point.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

offset = 0#
Type:

Float

Offset the text by a number of pixels (can be positive or negative). Shifts the text in different directions based on the location of the title:

  • above: shifts title right

  • right: shifts title down

  • below: shifts title right

  • left: shifts title up

padding = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative), Struct, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Extra space between the text of a label and its bounding box (border).

Note

This property is experimental and may change at any point.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

standoff = 10#
Type:

Float

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text = ''#
Type:

String

The text value to render.

text_alpha = 1.0#
Type:

Alpha

An alpha value to use to fill text with.

Acceptable values are floating-point numbers between 0 and 1 (0 being transparent and 1 being opaque).

text_color = '#444444'#
Type:

Color

A color to use to fill text with.

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

text_font = 'helvetica'#
Type:

String

Name of a font to use for rendering text, e.g., 'times', 'helvetica'.

text_font_style = 'bold'#
Type:

Enum(FontStyle)

A style to use for rendering text.

Acceptable values are:

  • 'normal' normal text

  • 'italic' italic text

  • 'bold' bold text

text_line_height = 1.0#
Type:

Float

How much additional space should be allocated for the title. The value is provided as a number, but should be treated as a percentage of font size. The default is 100%, which means no additional space will be used.

text_outline_color = None#
Type:

Nullable(Color)

A color to use to fill text with.

vertical_align = 'bottom'#
Type:

Enum(VerticalAlign)

Alignment of the text in its enclosing space, across the direction of the text.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ImperialLength(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: CustomDimensional

Imperial units of length measurement.

JSON Prototype
{
  "basis": {
    "entries": [
      [
        "in", 
        [
          0.08333333333333333, 
          "in", 
          "inch"
        ]
      ], 
      [
        "ft", 
        [
          1, 
          "ft", 
          "foot"
        ]
      ], 
      [
        "yd", 
        [
          3, 
          "yd", 
          "yard"
        ]
      ], 
      [
        "ch", 
        [
          66, 
          "ch", 
          "chain"
        ]
      ], 
      [
        "fur", 
        [
          660, 
          "fur", 
          "furlong"
        ]
      ], 
      [
        "mi", 
        [
          5280, 
          "mi", 
          "mile"
        ]
      ], 
      [
        "lea", 
        [
          15840, 
          "lea", 
          "league"
        ]
      ]
    ], 
    "type": "map"
  }, 
  "exclude": [], 
  "id": "p53208", 
  "include": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticks": [
    1, 
    3, 
    6, 
    12, 
    60
  ]
}
basis = {'in': (0.08333333333333333, 'in', 'inch'), 'ft': (1, 'ft', 'foot'), 'yd': (3, 'yd', 'yard'), 'ch': (66, 'ch', 'chain'), 'fur': (660, 'fur', 'furlong'), 'mi': (5280, 'mi', 'mile'), 'lea': (15840, 'lea', 'league')}#
Type:

Required(Dict(String, Either(Tuple(Float, String), Tuple(Float, String, String))))

The basis defining the units of measurement.

This consists of a mapping between short unit names and their corresponding scaling factors, TeX names and optional long names. For example, the basis for defining angular units of measurement is:

basis = {
    "°":  (1,      "^\circ",           "degree"),
    "'":  (1/60,   "^\prime",          "minute"),
    "''": (1/3600, "^{\prime\prime}", "second"),
}
exclude = []#
Type:

List

A subset of units from the basis to avoid.

include = None#
Type:

Nullable(List)

An optional subset of preferred units from the basis.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticks = [1, 3, 6, 12, 60]#
Type:

Required(List)

Preferred values to choose from in non-exact mode.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Label(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: TextAnnotation

Render a single text label as an annotation.

Label will render a single text label at given x and y coordinates, which can be in either screen (pixel) space, or data (axis range) space.

The label can also be configured with a screen space offset from x and y, by using the x_offset and y_offset properties.

Additionally, the label can be rotated with the angle property.

There are also standard text, fill, and line properties to control the appearance of the text, its background, as well as the rectangular bounding box border.

See Labels for information on plotting labels.

JSON Prototype
{
  "anchor": "auto", 
  "angle": 0, 
  "angle_units": "rad", 
  "background_fill_alpha": 1.0, 
  "background_fill_color": null, 
  "background_hatch_alpha": 1.0, 
  "background_hatch_color": null, 
  "background_hatch_extra": {
    "type": "map"
  }, 
  "background_hatch_pattern": null, 
  "background_hatch_scale": 12.0, 
  "background_hatch_weight": 1.0, 
  "border_line_alpha": 1.0, 
  "border_line_cap": "butt", 
  "border_line_color": null, 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "border_radius": 0, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "direction": "anticlock", 
  "editable": false, 
  "elements": [], 
  "group": null, 
  "id": "p53216", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "padding": 0, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "text": "", 
  "text_align": "left", 
  "text_alpha": 1.0, 
  "text_baseline": "bottom", 
  "text_color": "#444444", 
  "text_font": "helvetica", 
  "text_font_size": "16px", 
  "text_font_style": "normal", 
  "text_line_height": 1.2, 
  "text_outline_color": null, 
  "visible": true, 
  "x": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "x_offset": 0, 
  "x_range_name": "default", 
  "x_units": "data", 
  "y": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "y_offset": 0, 
  "y_range_name": "default", 
  "y_units": "data"
}
anchor = 'auto'#
Type:

Either(Either(Enum(Anchor), Tuple(Either(Enum(Align), Enum(HAlign), Percent), Either(Enum(Align), Enum(VAlign), Percent))), Auto)

Position within the bounding box of the text of a label to which x and y coordinates are anchored to.

Note

This property is experimental and may change at any point.

angle = 0#
Type:

Angle

The angle to rotate the text, as measured from the horizontal.

angle_units = 'rad'#
Type:

Enum(AngleUnits)

Acceptable values for units are "rad" and "deg".

background_fill_alpha = 1.0#
Type:

Alpha

The fill alpha values for the text bounding box.

background_fill_color = None#
Type:

Nullable(Color)

The fill color values for the text bounding box.

background_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the text bounding box.

background_hatch_color = None#
Type:

Nullable(Color)

The hatch color values for the text bounding box.

background_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the text bounding box.

background_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the text bounding box.

background_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the text bounding box.

background_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the text bounding box.

border_line_alpha = 1.0#
Type:

Alpha

The line alpha values for the text bounding box.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the text bounding box.

border_line_color = None#
Type:

Nullable(Color)

The line color values for the text bounding box.

border_line_dash = []#
Type:

DashPattern

The line dash values for the text bounding box.

border_line_dash_offset = 0#
Type:

Int

The line dash offset values for the text bounding box.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the text bounding box.

border_line_width = 1#
Type:

Float

The line width values for the text bounding box.

border_radius = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Allows label’s box to have rounded corners. For the best results, it should be used in combination with padding.

Note

This property is experimental and may change at any point.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

direction = 'anticlock'#
Type:

Enum(Direction)

The direction for the angle of the label.

Note

This property is experimental and may change at any point.

editable = False#
Type:

Bool

Allows to interactively modify the geometry of this label.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

padding = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative), Struct, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Extra space between the text of a label and its bounding box (border).

Note

This property is experimental and may change at any point.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text = ''#
Type:

TextLike

A text or LaTeX notation to render.

text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the text.

text_alpha = 1.0#
Type:

Alpha

The text alpha values for the text.

text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the text.

text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the text.

text_font = 'helvetica'#
Type:

String

The text font values for the text.

text_font_size = '16px'#
Type:

FontSize

The text font size values for the text.

text_font_style = 'normal'#
Type:

Enum(FontStyle)

The text font style values for the text.

text_line_height = 1.2#
Type:

Float

The text line height values for the text.

text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the text.

visible = True#
Type:

Bool

Is the renderer visible.

x = Undefined#
Type:

Required(Either(Either(Float, Datetime, Factor), Instance(Node)))

The x-coordinate in screen coordinates to locate the text anchors.

x_offset = 0#
Type:

Float

Offset value to apply to the x-coordinate.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

x_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the x attribute. Interpreted as data units by default. This doesn’t have any effect if x is a node.

y = Undefined#
Type:

Required(Either(Either(Float, Datetime, Factor), Instance(Node)))

The y-coordinate in screen coordinates to locate the text anchors.

y_offset = 0#
Type:

Float

Offset value to apply to the y-coordinate.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

y_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the y attribute. Interpreted as data units by default. This doesn’t have any effect if y is a node.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class LabelSet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: DataAnnotation

Render multiple text labels as annotations.

LabelSet will render multiple text labels at given x and y coordinates, which can be in either screen (pixel) space, or data (axis range) space. In this case (as opposed to the single Label model), x and y can also be the name of a column from a ColumnDataSource, in which case the labels will be “vectorized” using coordinate values from the specified columns.

The label can also be configured with a screen space offset from x and y, by using the x_offset and y_offset properties. These offsets may be vectorized by giving the name of a data source column.

Additionally, the label can be rotated with the angle property (which may also be a column name.)

There are also standard text, fill, and line properties to control the appearance of the text, its background, as well as the rectangular bounding box border.

The data source is provided by setting the source property.

JSON Prototype
{
  "angle": {
    "type": "value", 
    "value": 0
  }, 
  "background_fill_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "background_fill_color": {
    "type": "value", 
    "value": null
  }, 
  "border_line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "border_line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "border_line_color": {
    "type": "value", 
    "value": null
  }, 
  "border_line_dash": {
    "type": "value", 
    "value": []
  }, 
  "border_line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "border_line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "border_line_width": {
    "type": "value", 
    "value": 1
  }, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p53271", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "source": {
    "attributes": {
      "data": {
        "type": "map"
      }, 
      "selected": {
        "attributes": {
          "indices": [], 
          "line_indices": []
        }, 
        "id": "p53273", 
        "name": "Selection", 
        "type": "object"
      }, 
      "selection_policy": {
        "id": "p53274", 
        "name": "UnionRenderers", 
        "type": "object"
      }
    }, 
    "id": "p53272", 
    "name": "ColumnDataSource", 
    "type": "object"
  }, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "text": {
    "field": "text", 
    "type": "field"
  }, 
  "text_align": {
    "type": "value", 
    "value": "left"
  }, 
  "text_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "text_baseline": {
    "type": "value", 
    "value": "bottom"
  }, 
  "text_color": {
    "type": "value", 
    "value": "#444444"
  }, 
  "text_font": {
    "type": "value", 
    "value": "helvetica"
  }, 
  "text_font_size": {
    "type": "value", 
    "value": "16px"
  }, 
  "text_font_style": {
    "type": "value", 
    "value": "normal"
  }, 
  "text_line_height": {
    "type": "value", 
    "value": 1.2
  }, 
  "text_outline_color": {
    "type": "value", 
    "value": null
  }, 
  "visible": true, 
  "x": {
    "field": "x", 
    "type": "field"
  }, 
  "x_offset": {
    "type": "value", 
    "value": 0
  }, 
  "x_range_name": "default", 
  "x_units": "data", 
  "y": {
    "field": "y", 
    "type": "field"
  }, 
  "y_offset": {
    "type": "value", 
    "value": 0
  }, 
  "y_range_name": "default", 
  "y_units": "data"
}
angle = 0#
Type:

AngleSpec

The angles to rotate the text, as measured from the horizontal.

angle_units = 'rad'#
Type:

NotSerialized(Enum(AngleUnits))

Units to use for the associated property: deg, rad, grad or turn

background_fill_alpha = 1.0#
Type:

AlphaSpec

The fill alpha values for the text bounding box.

background_fill_color = None#
Type:

ColorSpec

The fill color values for the text bounding box.

border_line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the text bounding box.

border_line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the text bounding box.

border_line_color = None#
Type:

ColorSpec

The line color values for the text bounding box.

border_line_dash = []#
Type:

DashPatternSpec

The line dash values for the text bounding box.

border_line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the text bounding box.

border_line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the text bounding box.

border_line_width = 1#
Type:

NumberSpec

The line width values for the text bounding box.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

source = ColumnDataSource(id='p53359', ...)#
Type:

Instance(DataSource)

Local data source to use when rendering annotations on the plot.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text = Field(field='text', transform=Unspecified, units=Unspecified)#
Type:

NullStringSpec

The text values to render.

text_align = 'left'#
Type:

TextAlignSpec

The text align values for the text.

text_alpha = 1.0#
Type:

AlphaSpec

The text alpha values for the text.

text_baseline = 'bottom'#
Type:

TextBaselineSpec

The text baseline values for the text.

text_color = '#444444'#
Type:

ColorSpec

The text color values for the text.

text_font = Value(value='helvetica', transform=Unspecified, units=Unspecified)#
Type:

StringSpec

The text font values for the text.

text_font_size = Value(value='16px', transform=Unspecified, units=Unspecified)#
Type:

FontSizeSpec

The text font size values for the text.

text_font_style = 'normal'#
Type:

FontStyleSpec

The text font style values for the text.

text_line_height = 1.2#
Type:

NumberSpec

The text line height values for the text.

text_outline_color = None#
Type:

ColorSpec

The text outline color values for the text.

visible = True#
Type:

Bool

Is the renderer visible.

x = Field(field='x', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The x-coordinates to locate the text anchors.

x_offset = 0#
Type:

NumberSpec

Offset values to apply to the x-coordinates.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

x_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the xs attribute. Interpreted as data units by default.

y = Field(field='y', transform=Unspecified, units=Unspecified)#
Type:

NumberSpec

The y-coordinates to locate the text anchors.

y_offset = 0#
Type:

NumberSpec

Offset values to apply to the y-coordinates.

This is useful, for instance, if it is desired to “float” text a fixed distance in screen units from a given data position.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

y_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the ys attribute. Interpreted as data units by default.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Legend(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation

Render informational legends for a plot.

See Legends for information on plotting legends.

JSON Prototype
{
  "background_fill_alpha": 0.95, 
  "background_fill_color": "#ffffff", 
  "border_line_alpha": 0.5, 
  "border_line_cap": "butt", 
  "border_line_color": "#e5e5e5", 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "click_policy": "none", 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "glyph_height": 20, 
  "glyph_width": 20, 
  "group": null, 
  "id": "p53454", 
  "inactive_fill_alpha": 0.7, 
  "inactive_fill_color": "white", 
  "item_background_fill_alpha": 0.8, 
  "item_background_fill_color": "#f1f1f1", 
  "item_background_policy": "none", 
  "items": [], 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "label_height": 20, 
  "label_standoff": 5, 
  "label_text_align": "left", 
  "label_text_alpha": 1.0, 
  "label_text_baseline": "middle", 
  "label_text_color": "#444444", 
  "label_text_font": "helvetica", 
  "label_text_font_size": "13px", 
  "label_text_font_style": "normal", 
  "label_text_line_height": 1.2, 
  "label_text_outline_color": null, 
  "label_width": 20, 
  "level": "annotation", 
  "location": "top_right", 
  "margin": 10, 
  "name": null, 
  "ncols": "auto", 
  "nrows": "auto", 
  "orientation": "vertical", 
  "padding": 10, 
  "propagate_hover": false, 
  "renderers": [], 
  "spacing": 3, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "title": null, 
  "title_location": "above", 
  "title_standoff": 5, 
  "title_text_align": "left", 
  "title_text_alpha": 1.0, 
  "title_text_baseline": "bottom", 
  "title_text_color": "#444444", 
  "title_text_font": "helvetica", 
  "title_text_font_size": "13px", 
  "title_text_font_style": "italic", 
  "title_text_line_height": 1.2, 
  "title_text_outline_color": null, 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
background_fill_alpha = 0.95#
Type:

Alpha

The fill alpha for the legend background style.

background_fill_color = '#ffffff'#
Type:

Nullable(Color)

The fill color for the legend background style.

border_line_alpha = 0.5#
Type:

Alpha

The line alpha for the legend border outline.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap for the legend border outline.

border_line_color = '#e5e5e5'#
Type:

Nullable(Color)

The line color for the legend border outline.

border_line_dash = []#
Type:

DashPattern

The line dash for the legend border outline.

border_line_dash_offset = 0#
Type:

Int

The line dash offset for the legend border outline.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join for the legend border outline.

border_line_width = 1#
Type:

Float

The line width for the legend border outline.

click_policy = 'none'#
Type:

Enum(LegendClickPolicy)

Defines what happens when a lengend’s item is clicked.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

glyph_height = 20#
Type:

Int

The height (in pixels) that the rendered legend glyph should occupy.

glyph_width = 20#
Type:

Int

The width (in pixels) that the rendered legend glyph should occupy.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

inactive_fill_alpha = 0.7#
Type:

Alpha

The fill alpha for the legend item style when inactive. These control an overlay on the item that can be used to obscure it when the corresponding glyph is inactive (e.g. by making it semi-transparent).

inactive_fill_color = 'white'#
Type:

Nullable(Color)

The fill color for the legend item style when inactive. These control an overlay on the item that can be used to obscure it when the corresponding glyph is inactive (e.g. by making it semi-transparent).

item_background_fill_alpha = 0.8#
Type:

Alpha

The fill alpha for the legend items’ background style.

item_background_fill_color = '#f1f1f1'#
Type:

Nullable(Color)

The fill color for the legend items’ background style.

item_background_policy = 'none'#
Type:

Enum(AlternationPolicy)

Defines which items to style, if item_background_fill is configured.

items = []#
Type:

List

A list of LegendItem instances to be rendered in the legend.

This can be specified explicitly, for instance:

legend = Legend(items=[
    LegendItem(label="sin(x)",   renderers=[r0, r1]),
    LegendItem(label="2*sin(x)", renderers=[r2]),
    LegendItem(label="3*sin(x)", renderers=[r3, r4])
])

But as a convenience, can also be given more compactly as a list of tuples:

legend = Legend(items=[
    ("sin(x)",   [r0, r1]),
    ("2*sin(x)", [r2]),
    ("3*sin(x)", [r3, r4])
])

where each tuple is of the form: (label, renderers).

label_height = 20#
Type:

Int

The minimum height (in pixels) of the area that legend labels should occupy.

label_standoff = 5#
Type:

Int

The distance (in pixels) to separate the label from its associated glyph.

label_text_align = 'left'#
Type:

Enum(TextAlign)

The text align for the legend labels.

label_text_alpha = 1.0#
Type:

Alpha

The text alpha for the legend labels.

label_text_baseline = 'middle'#
Type:

Enum(TextBaseline)

The text baseline for the legend labels.

label_text_color = '#444444'#
Type:

Nullable(Color)

The text color for the legend labels.

label_text_font = 'helvetica'#
Type:

String

The text font for the legend labels.

label_text_font_size = '13px'#
Type:

FontSize

The text font size for the legend labels.

label_text_font_style = 'normal'#
Type:

Enum(FontStyle)

The text font style for the legend labels.

label_text_line_height = 1.2#
Type:

Float

The text line height for the legend labels.

label_text_outline_color = None#
Type:

Nullable(Color)

The text outline color for the legend labels.

label_width = 20#
Type:

Int

The minimum width (in pixels) of the area that legend labels should occupy.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

location = 'top_right'#
Type:

Either(Enum(Anchor), Tuple(Float, Float))

The location where the legend should draw itself. It’s either one of LegendLocation’s enumerated values, or a (x, y) tuple indicating an absolute location absolute location in screen coordinates (pixels from the bottom-left corner).

margin = 10#
Type:

Int

Amount of margin around the legend.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

ncols = 'auto'#
Type:

Either(Positive, Auto)

The number of columns in the legend’s layout. By default it’s either one column if the orientation is vertical or the number of items in the legend otherwise. ncols takes precendence over nrows for horizonal orientation.

nrows = 'auto'#
Type:

Either(Positive, Auto)

The number of rows in the legend’s layout. By default it’s either one row if the orientation is horizonal or the number of items in the legend otherwise. nrows takes precendence over ncols for vertical orientation.

orientation = 'vertical'#
Type:

Enum(Orientation)

Whether the legend entries should be placed vertically or horizontally when they are drawn.

padding = 10#
Type:

Int

Amount of padding around the contents of the legend. Only applicable when border is visible, otherwise collapses to 0.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

spacing = 3#
Type:

Int

Amount of spacing (in pixels) between legend entries.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

title = None#
Type:

Nullable(String)

The title text to render.

title_location = 'above'#
Type:

Enum(Location)

Specifies on which side of the legend the title will be located. Titles on the left or right side will be rotated accordingly.

title_standoff = 5#
Type:

Int

The distance (in pixels) to separate the title from the legend.

title_text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the title text.

title_text_alpha = 1.0#
Type:

Alpha

The text alpha values for the title text.

title_text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the title text.

title_text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the title text.

title_text_font = 'helvetica'#
Type:

String

The text font values for the title text.

title_text_font_size = '13px'#
Type:

FontSize

The text font size values for the title text.

title_text_font_style = 'italic'#
Type:

Enum(FontStyle)

The text font style values for the title text.

title_text_line_height = 1.2#
Type:

Float

The text line height values for the title text.

title_text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the title text.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_on_click(handler: JsEventCallback) None[source]#

Set up a JavaScript handler for legend item clicks.

classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_click(handler: PyEventCallback) None[source]#

Set up a handler for legend item clicks.

on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class LegendItem(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Model

JSON Prototype
{
  "id": "p53520", 
  "index": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "label": {
    "type": "value", 
    "value": null
  }, 
  "name": null, 
  "renderers": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "visible": true
}
index = None#
Type:

Nullable(Int)

The column data index to use for drawing the representative items.

If None (the default), then Bokeh will automatically choose an index to use. If the label does not refer to a data column name, this is typically the first data point in the data source. Otherwise, if the label does refer to a column name, the legend will have “groupby” behavior, and will choose and display representative points from every “group” in the column.

If set to a number, Bokeh will use that number as the index in all cases.

label = None#
Type:

NullStringSpec

A label for this legend. Can be a string, or a column of a ColumnDataSource. If label is a field, then it must be in the renderers’ data_source.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

renderers = []#
Type:

List

A list of the glyph renderers to draw in the legend. If label is a field, then all data_sources of renderers must be the same.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

visible = True#
Type:

Bool

Whether the legend item should be displayed. See Hiding legend items in the user guide.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Metric(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Dimensional

Model for defining metric units of measurement.

JSON Prototype
{
  "base_unit": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "exclude": [], 
  "full_unit": null, 
  "id": "p53528", 
  "include": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticks": [
    1, 
    2, 
    5, 
    10, 
    15, 
    20, 
    25, 
    50, 
    75, 
    100, 
    125, 
    150, 
    200, 
    250, 
    500, 
    750
  ]
}
base_unit = Undefined#
Type:

Required(String)

The short name of the base unit, e.g. "m" for meters or "eV" for electron volts.

exclude = []#
Type:

List

A subset of units from the basis to avoid.

full_unit = None#
Type:

Nullable(String)

The full name of the base unit, e.g. "meter" or "electronvolt".

include = None#
Type:

Nullable(List)

An optional subset of preferred units from the basis.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticks = [1, 2, 5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 200, 250, 500, 750]#
Type:

Required(List)

Preferred values to choose from in non-exact mode.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class MetricLength(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Metric

Metric units of length measurement.

JSON Prototype
{
  "base_unit": "m", 
  "exclude": [
    "dm", 
    "hm"
  ], 
  "full_unit": null, 
  "id": "p53537", 
  "include": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticks": [
    1, 
    2, 
    5, 
    10, 
    15, 
    20, 
    25, 
    50, 
    75, 
    100, 
    125, 
    150, 
    200, 
    250, 
    500, 
    750
  ]
}
base_unit = 'm'#
Type:

Required(String)

The short name of the base unit, e.g. "m" for meters or "eV" for electron volts.

exclude = ['dm', 'hm']#
Type:

List

A subset of units from the basis to avoid.

full_unit = None#
Type:

Nullable(String)

The full name of the base unit, e.g. "meter" or "electronvolt".

include = None#
Type:

Nullable(List)

An optional subset of preferred units from the basis.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticks = [1, 2, 5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 200, 250, 500, 750]#
Type:

Required(List)

Preferred values to choose from in non-exact mode.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class NormalHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: ArrowHead

Render a closed-body arrow head.

JSON Prototype
{
  "fill_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "fill_color": {
    "type": "value", 
    "value": "black"
  }, 
  "id": "p53546", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "line_color": {
    "type": "value", 
    "value": "black"
  }, 
  "line_dash": {
    "type": "value", 
    "value": []
  }, 
  "line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "line_width": {
    "type": "value", 
    "value": 1
  }, 
  "name": null, 
  "size": {
    "type": "value", 
    "value": 25
  }, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": []
}
fill_alpha = 1.0#
Type:

AlphaSpec

The fill alpha values for the arrow head interior.

fill_color = 'black'#
Type:

ColorSpec

The fill color values for the arrow head interior.

line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the arrow head outline.

line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the arrow head outline.

line_color = 'black'#
Type:

ColorSpec

The line color values for the arrow head outline.

line_dash = []#
Type:

DashPatternSpec

The line dash values for the arrow head outline.

line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the arrow head outline.

line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the arrow head outline.

line_width = 1#
Type:

NumberSpec

The line width values for the arrow head outline.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

size = 25#
Type:

NumberSpec

The size, in pixels, of the arrow head.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class OpenHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: ArrowHead

Render an open-body arrow head.

JSON Prototype
{
  "id": "p53560", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "line_color": {
    "type": "value", 
    "value": "black"
  }, 
  "line_dash": {
    "type": "value", 
    "value": []
  }, 
  "line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "line_width": {
    "type": "value", 
    "value": 1
  }, 
  "name": null, 
  "size": {
    "type": "value", 
    "value": 25
  }, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": []
}
line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the arrow head outline.

line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the arrow head outline.

line_color = 'black'#
Type:

ColorSpec

The line color values for the arrow head outline.

line_dash = []#
Type:

DashPatternSpec

The line dash values for the arrow head outline.

line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the arrow head outline.

line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the arrow head outline.

line_width = 1#
Type:

NumberSpec

The line width values for the arrow head outline.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

size = 25#
Type:

NumberSpec

The size, in pixels, of the arrow head.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class PolyAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation

Render a shaded polygonal region as an annotation.

See Polygon annotations for information on plotting polygon annotations.

JSON Prototype
{
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "editable": false, 
  "elements": [], 
  "fill_alpha": 0.4, 
  "fill_color": "#fff9ba", 
  "group": null, 
  "hatch_alpha": 1.0, 
  "hatch_color": "black", 
  "hatch_extra": {
    "type": "map"
  }, 
  "hatch_pattern": null, 
  "hatch_scale": 12.0, 
  "hatch_weight": 1.0, 
  "hover_fill_alpha": 0.4, 
  "hover_fill_color": null, 
  "hover_hatch_alpha": 1.0, 
  "hover_hatch_color": "black", 
  "hover_hatch_extra": {
    "type": "map"
  }, 
  "hover_hatch_pattern": null, 
  "hover_hatch_scale": 12.0, 
  "hover_hatch_weight": 1.0, 
  "hover_line_alpha": 0.3, 
  "hover_line_cap": "butt", 
  "hover_line_color": null, 
  "hover_line_dash": [], 
  "hover_line_dash_offset": 0, 
  "hover_line_join": "bevel", 
  "hover_line_width": 1, 
  "id": "p53572", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "line_alpha": 0.3, 
  "line_cap": "butt", 
  "line_color": "#cccccc", 
  "line_dash": [], 
  "line_dash_offset": 0, 
  "line_join": "bevel", 
  "line_width": 1, 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "visible": true, 
  "x_range_name": "default", 
  "xs": [], 
  "xs_units": "data", 
  "y_range_name": "default", 
  "ys": [], 
  "ys_units": "data"
}
context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

editable = False#
Type:

Bool

Allows to interactively modify the geometry of this polygon.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

fill_alpha = 0.4#
Type:

Alpha

The fill alpha values for the polygon.

fill_color = '#fff9ba'#
Type:

Nullable(Color)

The fill color values for the polygon.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the polygon.

hatch_color = 'black'#
Type:

Nullable(Color)

The hatch color values for the polygon.

hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the polygon.

hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the polygon.

hatch_scale = 12.0#
Type:

Size

The hatch scale values for the polygon.

hatch_weight = 1.0#
Type:

Size

The hatch weight values for the polygon.

hover_fill_alpha = 0.4#
Type:

Alpha

The fill alpha values for the polygon when hovering over.

hover_fill_color = None#
Type:

Nullable(Color)

The fill color values for the polygon when hovering over.

hover_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the polygon when hovering over.

hover_hatch_color = 'black'#
Type:

Nullable(Color)

The hatch color values for the polygon when hovering over.

hover_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the polygon when hovering over.

hover_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the polygon when hovering over.

hover_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the polygon when hovering over.

hover_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the polygon when hovering over.

hover_line_alpha = 0.3#
Type:

Alpha

The line alpha values for the polygon when hovering over.

hover_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the polygon when hovering over.

hover_line_color = None#
Type:

Nullable(Color)

The line color values for the polygon when hovering over.

hover_line_dash = []#
Type:

DashPattern

The line dash values for the polygon when hovering over.

hover_line_dash_offset = 0#
Type:

Int

The line dash offset values for the polygon when hovering over.

hover_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the polygon when hovering over.

hover_line_width = 1#
Type:

Float

The line width values for the polygon when hovering over.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

line_alpha = 0.3#
Type:

Alpha

The line alpha values for the polygon.

line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the polygon.

line_color = '#cccccc'#
Type:

Nullable(Color)

The line color values for the polygon.

line_dash = []#
Type:

DashPattern

The line dash values for the polygon.

line_dash_offset = 0#
Type:

Int

The line dash offset values for the polygon.

line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the polygon.

line_width = 1#
Type:

Float

The line width values for the polygon.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

xs = []#
Type:

Seq(Either(Float, Datetime, Factor))

The x-coordinates of the region to draw.

xs_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the xs attribute. Interpreted as data units by default.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

ys = []#
Type:

Seq(Either(Float, Datetime, Factor))

The y-coordinates of the region to draw.

ys_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the ys attribute. Interpreted as data units by default.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ReciprocalMetric(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Metric

Model for defining reciprocal metric units of measurement, e.g. m^{-1}.

JSON Prototype
{
  "base_unit": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "exclude": [], 
  "full_unit": null, 
  "id": "p53624", 
  "include": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticks": [
    1, 
    2, 
    5, 
    10, 
    15, 
    20, 
    25, 
    50, 
    75, 
    100, 
    125, 
    150, 
    200, 
    250, 
    500, 
    750
  ]
}
base_unit = Undefined#
Type:

Required(String)

The short name of the base unit, e.g. "m" for meters or "eV" for electron volts.

exclude = []#
Type:

List

A subset of units from the basis to avoid.

full_unit = None#
Type:

Nullable(String)

The full name of the base unit, e.g. "meter" or "electronvolt".

include = None#
Type:

Nullable(List)

An optional subset of preferred units from the basis.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticks = [1, 2, 5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 200, 250, 500, 750]#
Type:

Required(List)

Preferred values to choose from in non-exact mode.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ReciprocalMetricLength(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: ReciprocalMetric

Metric units of reciprocal length measurement.

JSON Prototype
{
  "base_unit": "m", 
  "exclude": [
    "dm", 
    "hm"
  ], 
  "full_unit": null, 
  "id": "p53633", 
  "include": null, 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "name": null, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticks": [
    1, 
    2, 
    5, 
    10, 
    15, 
    20, 
    25, 
    50, 
    75, 
    100, 
    125, 
    150, 
    200, 
    250, 
    500, 
    750
  ]
}
base_unit = 'm'#
Type:

Required(String)

The short name of the base unit, e.g. "m" for meters or "eV" for electron volts.

exclude = ['dm', 'hm']#
Type:

List

A subset of units from the basis to avoid.

full_unit = None#
Type:

Nullable(String)

The full name of the base unit, e.g. "meter" or "electronvolt".

include = None#
Type:

Nullable(List)

An optional subset of preferred units from the basis.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticks = [1, 2, 5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 200, 250, 500, 750]#
Type:

Required(List)

Preferred values to choose from in non-exact mode.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ScaleBar(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation

Represents a scale bar annotation.

JSON Prototype
{
  "background_fill_alpha": 0.95, 
  "background_fill_color": "#ffffff", 
  "background_hatch_alpha": 1.0, 
  "background_hatch_color": "black", 
  "background_hatch_extra": {
    "type": "map"
  }, 
  "background_hatch_pattern": null, 
  "background_hatch_scale": 12.0, 
  "background_hatch_weight": 1.0, 
  "bar_length": 0.2, 
  "bar_line_alpha": 1.0, 
  "bar_line_cap": "butt", 
  "bar_line_color": "black", 
  "bar_line_dash": [], 
  "bar_line_dash_offset": 0, 
  "bar_line_join": "bevel", 
  "bar_line_width": 2, 
  "border_line_alpha": 0.5, 
  "border_line_cap": "butt", 
  "border_line_color": "#e5e5e5", 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "dimensional": {
    "attributes": {
      "include": null
    }, 
    "id": "p53643", 
    "name": "MetricLength", 
    "type": "object"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p53642", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "label": "@{value} @{unit}", 
  "label_align": "center", 
  "label_location": "below", 
  "label_standoff": 5, 
  "label_text_align": "left", 
  "label_text_alpha": 1.0, 
  "label_text_baseline": "middle", 
  "label_text_color": "#444444", 
  "label_text_font": "helvetica", 
  "label_text_font_size": "13px", 
  "label_text_font_style": "normal", 
  "label_text_line_height": 1.2, 
  "label_text_outline_color": null, 
  "length_sizing": "adaptive", 
  "level": "annotation", 
  "location": "top_right", 
  "margin": 10, 
  "name": null, 
  "orientation": "horizontal", 
  "padding": 10, 
  "propagate_hover": false, 
  "range": "auto", 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "ticker": {
    "attributes": {
      "minor_ticks": [], 
      "ticks": []
    }, 
    "id": "p53644", 
    "name": "FixedTicker", 
    "type": "object"
  }, 
  "title": "", 
  "title_align": "center", 
  "title_location": "above", 
  "title_standoff": 5, 
  "title_text_align": "left", 
  "title_text_alpha": 1.0, 
  "title_text_baseline": "bottom", 
  "title_text_color": "#444444", 
  "title_text_font": "helvetica", 
  "title_text_font_size": "13px", 
  "title_text_font_style": "italic", 
  "title_text_line_height": 1.2, 
  "title_text_outline_color": null, 
  "unit": "m", 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
background_fill_alpha = 0.95#
Type:

Alpha

The fill alpha for the scale bar background fill style.

background_fill_color = '#ffffff'#
Type:

Nullable(Color)

The fill color for the scale bar background fill style.

background_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha for the scale bar background hatch style.

background_hatch_color = 'black'#
Type:

Nullable(Color)

The hatch color for the scale bar background hatch style.

background_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra for the scale bar background hatch style.

background_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern for the scale bar background hatch style.

background_hatch_scale = 12.0#
Type:

Size

The hatch scale for the scale bar background hatch style.

background_hatch_weight = 1.0#
Type:

Size

The hatch weight for the scale bar background hatch style.

bar_length = 0.2#
Type:

NonNegative

The length of the bar, either a fraction of the frame or a number of pixels.

bar_line_alpha = 1.0#
Type:

Alpha

The line alpha values for the bar line style.

bar_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the bar line style.

bar_line_color = 'black'#
Type:

Nullable(Color)

The line color values for the bar line style.

bar_line_dash = []#
Type:

DashPattern

The line dash values for the bar line style.

bar_line_dash_offset = 0#
Type:

Int

The line dash offset values for the bar line style.

bar_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the bar line style.

bar_line_width = 2#
Type:

Float

The line width values for the bar line style.

border_line_alpha = 0.5#
Type:

Alpha

The line alpha for the scale bar border line style.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap for the scale bar border line style.

border_line_color = '#e5e5e5'#
Type:

Nullable(Color)

The line color for the scale bar border line style.

border_line_dash = []#
Type:

DashPattern

The line dash for the scale bar border line style.

border_line_dash_offset = 0#
Type:

Int

The line dash offset for the scale bar border line style.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join for the scale bar border line style.

border_line_width = 1#
Type:

Float

The line width for the scale bar border line style.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

dimensional = MetricLength(id='p53726', ...)#
Type:

Instance(Dimensional)

Defines the units of measurement.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

label = '@{value} @{unit}'#
Type:

String

The label template.

This can use special variables:

  • @{value} The current value. Optionally can provide a number formatter with e.g. @{value}{%.2f}.

  • @{unit} The unit of measurement.

label_align = 'center'#
Type:

Enum(Align)

Specifies where to align scale bar’s label along the bar.

This property effective when placing the label above or below a horizontal scale bar, or left or right of a vertical one.

label_location = 'below'#
Type:

Enum(Location)

Specifies on which side of the scale bar the label will be located.

label_standoff = 5#
Type:

Int

The distance (in pixels) to separate the label from the scale bar.

label_text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the label text style.

label_text_alpha = 1.0#
Type:

Alpha

The text alpha values for the label text style.

label_text_baseline = 'middle'#
Type:

Enum(TextBaseline)

The text baseline values for the label text style.

label_text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the label text style.

label_text_font = 'helvetica'#
Type:

String

The text font values for the label text style.

label_text_font_size = '13px'#
Type:

FontSize

The text font size values for the label text style.

label_text_font_style = 'normal'#
Type:

Enum(FontStyle)

The text font style values for the label text style.

label_text_line_height = 1.2#
Type:

Float

The text line height values for the label text style.

label_text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the label text style.

length_sizing = 'adaptive'#
Type:

Enum(Enumeration(adaptive, exact))

Defines how the length of the bar is interpreted.

This can either be:

  • "adaptive" - the computed length is fit into a set of ticks provided be the dimensional model. If no ticks are provided, then the behavior is the same as if "exact" sizing was used

  • "exact" - the computed length is used as-is

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

location = 'top_right'#
Type:

Enum(Anchor)

Location anchor for positioning scale bar.

margin = 10#
Type:

Int

Amount of margin (in pixels) around the outside of the scale bar.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

orientation = 'horizontal'#
Type:

Enum(Orientation)

Whether the scale bar should be oriented horizontally or vertically.

padding = 10#
Type:

Int

Amount of padding (in pixels) between the contents of the scale bar and its border.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

range = 'auto'#
Type:

Either(Instance(Range), Auto)

The range for which to display the scale.

This can be either a range reference or "auto", in which case the scale bar will pick the default x or y range of the frame, depending on the orientation of the scale bar.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

ticker = FixedTicker(id='p53817', ...)#
Type:

Instance(Ticker)

A ticker to use for computing locations of axis components.

Note that if using the default fixed ticker with no predefined ticks, then the appearance of the scale bar will be just a solid bar with no additional markings.

title = ''#
Type:

String

The title text to render.

title_align = 'center'#
Type:

Enum(Align)

Specifies where to align scale bar’s title along the bar.

This property effective when placing the title above or below a horizontal scale bar, or left or right of a vertical one.

title_location = 'above'#
Type:

Enum(Location)

Specifies on which side of the legend the title will be located.

title_standoff = 5#
Type:

Int

The distance (in pixels) to separate the title from the scale bar.

title_text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the title text style.

title_text_alpha = 1.0#
Type:

Alpha

The text alpha values for the title text style.

title_text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the title text style.

title_text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the title text style.

title_text_font = 'helvetica'#
Type:

String

The text font values for the title text style.

title_text_font_size = '13px'#
Type:

FontSize

The text font size values for the title text style.

title_text_font_style = 'italic'#
Type:

Enum(FontStyle)

The text font style values for the title text style.

title_text_line_height = 1.2#
Type:

Float

The text line height values for the title text style.

title_text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the title text style.

unit = 'm'#
Type:

String

The unit of the range property.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Slope(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation

Render a sloped line as an annotation.

See Slopes for information on plotting slopes.

JSON Prototype
{
  "above_fill_alpha": 0.4, 
  "above_fill_color": null, 
  "above_hatch_alpha": 1.0, 
  "above_hatch_color": "black", 
  "above_hatch_extra": {
    "type": "map"
  }, 
  "above_hatch_pattern": null, 
  "above_hatch_scale": 12.0, 
  "above_hatch_weight": 1.0, 
  "below_fill_alpha": 0.4, 
  "below_fill_color": null, 
  "below_hatch_alpha": 1.0, 
  "below_hatch_color": "black", 
  "below_hatch_extra": {
    "type": "map"
  }, 
  "below_hatch_pattern": null, 
  "below_hatch_scale": 12.0, 
  "below_hatch_weight": 1.0, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "gradient": null, 
  "group": null, 
  "id": "p53869", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "line_alpha": 1.0, 
  "line_cap": "butt", 
  "line_color": "black", 
  "line_dash": [], 
  "line_dash_offset": 0, 
  "line_join": "bevel", 
  "line_width": 1, 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "visible": true, 
  "x_range_name": "default", 
  "y_intercept": null, 
  "y_range_name": "default"
}
above_fill_alpha = 0.4#
Type:

Alpha

The fill alpha values for the area above the line.

above_fill_color = None#
Type:

Nullable(Color)

The fill color values for the area above the line.

above_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the area above the line.

above_hatch_color = 'black'#
Type:

Nullable(Color)

The hatch color values for the area above the line.

above_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the area above the line.

above_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the area above the line.

above_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the area above the line.

above_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the area above the line.

below_fill_alpha = 0.4#
Type:

Alpha

The fill alpha values for the area below the line.

below_fill_color = None#
Type:

Nullable(Color)

The fill color values for the area below the line.

below_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the area below the line.

below_hatch_color = 'black'#
Type:

Nullable(Color)

The hatch color values for the area below the line.

below_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the area below the line.

below_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the area below the line.

below_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the area below the line.

below_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the area below the line.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

gradient = None#
Type:

Nullable(Float)

The gradient of the line, in data units

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

line_alpha = 1.0#
Type:

Alpha

The line alpha values for the line.

line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the line.

line_color = 'black'#
Type:

Nullable(Color)

The line color values for the line.

line_dash = []#
Type:

DashPattern

The line dash values for the line.

line_dash_offset = 0#
Type:

Int

The line dash offset values for the line.

line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the line.

line_width = 1#
Type:

Float

The line width values for the line.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_intercept = None#
Type:

Nullable(Float)

The y intercept of the line, in data units

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Span(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation

Render a horizontal or vertical line span.

See Spans for information on plotting spans.

JSON Prototype
{
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "dimension": "width", 
  "editable": false, 
  "elements": [], 
  "group": null, 
  "hover_line_alpha": 0.3, 
  "hover_line_cap": "butt", 
  "hover_line_color": null, 
  "hover_line_dash": [], 
  "hover_line_dash_offset": 0, 
  "hover_line_join": "bevel", 
  "hover_line_width": 1, 
  "id": "p53911", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "line_alpha": 1.0, 
  "line_cap": "butt", 
  "line_color": "black", 
  "line_dash": [], 
  "line_dash_offset": 0, 
  "line_join": "bevel", 
  "line_width": 1, 
  "location": null, 
  "location_units": "data", 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

dimension = 'width'#
Type:

Enum(Dimension)

The direction of the span can be specified by setting this property to “height” (y direction) or “width” (x direction).

editable = False#
Type:

Bool

Allows to interactively modify the geometry of this span.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

hover_line_alpha = 0.3#
Type:

Alpha

The line alpha values for the span when hovering over.

hover_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the span when hovering over.

hover_line_color = None#
Type:

Nullable(Color)

The line color values for the span when hovering over.

hover_line_dash = []#
Type:

DashPattern

The line dash values for the span when hovering over.

hover_line_dash_offset = 0#
Type:

Int

The line dash offset values for the span when hovering over.

hover_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the span when hovering over.

hover_line_width = 1#
Type:

Float

The line width values for the span when hovering over.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

line_alpha = 1.0#
Type:

Alpha

The line alpha values for the span.

line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the span.

line_color = 'black'#
Type:

Nullable(Color)

The line color values for the span.

line_dash = []#
Type:

DashPattern

The line dash values for the span.

line_dash_offset = 0#
Type:

Int

The line dash offset values for the span.

line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the span.

line_width = 1#
Type:

Float

The line width values for the span.

location = None#
Type:

Nullable(Either(Float, Datetime, Factor))

The location of the span, along dimension.

location_units = 'data'#
Type:

Enum(CoordinateUnits)

The unit type for the location attribute. Interpreted as “data space” units by default.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class TeeHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: ArrowHead

Render a tee-style arrow head.

JSON Prototype
{
  "id": "p53946", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "line_color": {
    "type": "value", 
    "value": "black"
  }, 
  "line_dash": {
    "type": "value", 
    "value": []
  }, 
  "line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "line_width": {
    "type": "value", 
    "value": 1
  }, 
  "name": null, 
  "size": {
    "type": "value", 
    "value": 25
  }, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": []
}
line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the arrow head outline.

line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the arrow head outline.

line_color = 'black'#
Type:

ColorSpec

The line color values for the arrow head outline.

line_dash = []#
Type:

DashPatternSpec

The line dash values for the arrow head outline.

line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the arrow head outline.

line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the arrow head outline.

line_width = 1#
Type:

NumberSpec

The line width values for the arrow head outline.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

size = 25#
Type:

NumberSpec

The size, in pixels, of the arrow head.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class TextAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Annotation

Base class for text annotation models such as labels and titles.

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.

JSON Prototype
{
  "background_fill_alpha": 1.0, 
  "background_fill_color": null, 
  "background_hatch_alpha": 1.0, 
  "background_hatch_color": null, 
  "background_hatch_extra": {
    "type": "map"
  }, 
  "background_hatch_pattern": null, 
  "background_hatch_scale": 12.0, 
  "background_hatch_weight": 1.0, 
  "border_line_alpha": 1.0, 
  "border_line_cap": "butt", 
  "border_line_color": null, 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "border_radius": 0, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p53958", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "padding": 0, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "text": "", 
  "text_align": "left", 
  "text_alpha": 1.0, 
  "text_baseline": "bottom", 
  "text_color": "#444444", 
  "text_font": "helvetica", 
  "text_font_size": "16px", 
  "text_font_style": "normal", 
  "text_line_height": 1.2, 
  "text_outline_color": null, 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
background_fill_alpha = 1.0#
Type:

Alpha

The fill alpha values for the text bounding box.

background_fill_color = None#
Type:

Nullable(Color)

The fill color values for the text bounding box.

background_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the text bounding box.

background_hatch_color = None#
Type:

Nullable(Color)

The hatch color values for the text bounding box.

background_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the text bounding box.

background_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the text bounding box.

background_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the text bounding box.

background_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the text bounding box.

border_line_alpha = 1.0#
Type:

Alpha

The line alpha values for the text bounding box.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the text bounding box.

border_line_color = None#
Type:

Nullable(Color)

The line color values for the text bounding box.

border_line_dash = []#
Type:

DashPattern

The line dash values for the text bounding box.

border_line_dash_offset = 0#
Type:

Int

The line dash offset values for the text bounding box.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the text bounding box.

border_line_width = 1#
Type:

Float

The line width values for the text bounding box.

border_radius = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Allows label’s box to have rounded corners. For the best results, it should be used in combination with padding.

Note

This property is experimental and may change at any point.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

padding = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative), Struct, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Extra space between the text of a label and its bounding box (border).

Note

This property is experimental and may change at any point.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text = ''#
Type:

TextLike

A text or LaTeX notation to render.

text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the text.

text_alpha = 1.0#
Type:

Alpha

The text alpha values for the text.

text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the text.

text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the text.

text_font = 'helvetica'#
Type:

String

The text font values for the text.

text_font_size = '16px'#
Type:

FontSize

The text font size values for the text.

text_font_style = 'normal'#
Type:

Enum(FontStyle)

The text font style values for the text.

text_line_height = 1.2#
Type:

Float

The text line height values for the text.

text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the text.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Title(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: TextAnnotation

Render a single title box as an annotation.

See Titles for information on plotting titles.

JSON Prototype
{
  "align": "left", 
  "background_fill_alpha": 1.0, 
  "background_fill_color": null, 
  "background_hatch_alpha": 1.0, 
  "background_hatch_color": null, 
  "background_hatch_extra": {
    "type": "map"
  }, 
  "background_hatch_pattern": null, 
  "background_hatch_scale": 12.0, 
  "background_hatch_weight": 1.0, 
  "border_line_alpha": 1.0, 
  "border_line_cap": "butt", 
  "border_line_color": null, 
  "border_line_dash": [], 
  "border_line_dash_offset": 0, 
  "border_line_join": "bevel", 
  "border_line_width": 1, 
  "border_radius": 0, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p54002", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "offset": 0, 
  "padding": 0, 
  "propagate_hover": false, 
  "renderers": [], 
  "standoff": 10, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "text": "", 
  "text_align": "left", 
  "text_alpha": 1.0, 
  "text_baseline": "bottom", 
  "text_color": "#444444", 
  "text_font": "helvetica", 
  "text_font_size": "13px", 
  "text_font_style": "bold", 
  "text_line_height": 1.0, 
  "text_outline_color": null, 
  "vertical_align": "bottom", 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
align = 'left'#
Type:

Enum(TextAlign)

Alignment of the text in its enclosing space, along the direction of the text.

background_fill_alpha = 1.0#
Type:

Alpha

The fill alpha values for the text bounding box.

background_fill_color = None#
Type:

Nullable(Color)

The fill color values for the text bounding box.

background_hatch_alpha = 1.0#
Type:

Alpha

The hatch alpha values for the text bounding box.

background_hatch_color = None#
Type:

Nullable(Color)

The hatch color values for the text bounding box.

background_hatch_extra = {}#
Type:

Dict(String, Instance(Texture))

The hatch extra values for the text bounding box.

background_hatch_pattern = None#
Type:

Nullable(String)

The hatch pattern values for the text bounding box.

background_hatch_scale = 12.0#
Type:

Size

The hatch scale values for the text bounding box.

background_hatch_weight = 1.0#
Type:

Size

The hatch weight values for the text bounding box.

border_line_alpha = 1.0#
Type:

Alpha

The line alpha values for the text bounding box.

border_line_cap = 'butt'#
Type:

Enum(LineCap)

The line cap values for the text bounding box.

border_line_color = None#
Type:

Nullable(Color)

The line color values for the text bounding box.

border_line_dash = []#
Type:

DashPattern

The line dash values for the text bounding box.

border_line_dash_offset = 0#
Type:

Int

The line dash offset values for the text bounding box.

border_line_join = 'bevel'#
Type:

Enum(LineJoin)

The line join values for the text bounding box.

border_line_width = 1#
Type:

Float

The line width values for the text bounding box.

border_radius = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Allows label’s box to have rounded corners. For the best results, it should be used in combination with padding.

Note

This property is experimental and may change at any point.

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

offset = 0#
Type:

Float

Offset the text by a number of pixels (can be positive or negative). Shifts the text in different directions based on the location of the title:

  • above: shifts title right

  • right: shifts title down

  • below: shifts title right

  • left: shifts title up

padding = 0#
Type:

Either(NonNegative, Tuple(NonNegative, NonNegative), Struct, Tuple(NonNegative, NonNegative, NonNegative, NonNegative), Struct)

Extra space between the text of a label and its bounding box (border).

Note

This property is experimental and may change at any point.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

standoff = 10#
Type:

Float

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text = ''#
Type:

TextLike

A text or LaTeX notation to render.

text_align = 'left'#
Type:

Enum(TextAlign)

The text align values for the text.

text_alpha = 1.0#
Type:

Alpha

The text alpha values for the text.

text_baseline = 'bottom'#
Type:

Enum(TextBaseline)

The text baseline values for the text.

text_color = '#444444'#
Type:

Nullable(Color)

The text color values for the text.

text_font = 'helvetica'#
Type:

String

The text font values for the text.

text_font_size = '13px'#
Type:

FontSize

The text font size values for the text.

text_font_style = 'bold'#
Type:

Enum(FontStyle)

The text font style values for the text.

text_line_height = 1.0#
Type:

Float

The text line height values for the text.

text_outline_color = None#
Type:

Nullable(Color)

The text outline color values for the text.

vertical_align = 'bottom'#
Type:

Enum(VerticalAlign)

Alignment of the text in its enclosing space, across the direction of the text.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class ToolbarPanel(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLAnnotation

JSON Prototype
{
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "elements": [], 
  "group": null, 
  "id": "p54050", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "annotation", 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "toolbar": {
    "name": "unset", 
    "type": "symbol"
  }, 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'annotation'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

toolbar = Undefined#
Type:

Instance(Toolbar)

A toolbar to display.

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class VeeHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: ArrowHead

Render a vee-style arrow head.

JSON Prototype
{
  "fill_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "fill_color": {
    "type": "value", 
    "value": "black"
  }, 
  "id": "p54068", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "line_color": {
    "type": "value", 
    "value": "black"
  }, 
  "line_dash": {
    "type": "value", 
    "value": []
  }, 
  "line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "line_width": {
    "type": "value", 
    "value": 1
  }, 
  "name": null, 
  "size": {
    "type": "value", 
    "value": 25
  }, 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": []
}
fill_alpha = 1.0#
Type:

AlphaSpec

The fill alpha values for the arrow head interior.

fill_color = 'black'#
Type:

ColorSpec

The fill color values for the arrow head interior.

line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the arrow head outline.

line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the arrow head outline.

line_color = 'black'#
Type:

ColorSpec

The line color values for the arrow head outline.

line_dash = []#
Type:

DashPatternSpec

The line dash values for the arrow head outline.

line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the arrow head outline.

line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the arrow head outline.

line_width = 1#
Type:

NumberSpec

The line width values for the arrow head outline.

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

size = 25#
Type:

NumberSpec

The size, in pixels, of the arrow head.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)

class Whisker(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: DataAnnotation

Render a whisker along a dimension.

See Whiskers for information on plotting whiskers.

JSON Prototype
{
  "base": {
    "field": "base", 
    "type": "field"
  }, 
  "context_menu": null, 
  "coordinates": null, 
  "css_classes": [], 
  "css_variables": {
    "type": "map"
  }, 
  "dimension": "height", 
  "elements": [], 
  "group": null, 
  "id": "p54082", 
  "js_event_callbacks": {
    "type": "map"
  }, 
  "js_property_callbacks": {
    "type": "map"
  }, 
  "level": "underlay", 
  "line_alpha": {
    "type": "value", 
    "value": 1.0
  }, 
  "line_cap": {
    "type": "value", 
    "value": "butt"
  }, 
  "line_color": {
    "type": "value", 
    "value": "black"
  }, 
  "line_dash": {
    "type": "value", 
    "value": []
  }, 
  "line_dash_offset": {
    "type": "value", 
    "value": 0
  }, 
  "line_join": {
    "type": "value", 
    "value": "bevel"
  }, 
  "line_width": {
    "type": "value", 
    "value": 1
  }, 
  "lower": {
    "field": "lower", 
    "type": "field"
  }, 
  "lower_head": {
    "attributes": {
      "size": {
        "type": "value", 
        "value": 10
      }
    }, 
    "id": "p54086", 
    "name": "TeeHead", 
    "type": "object"
  }, 
  "name": null, 
  "propagate_hover": false, 
  "renderers": [], 
  "source": {
    "attributes": {
      "data": {
        "type": "map"
      }, 
      "selected": {
        "attributes": {
          "indices": [], 
          "line_indices": []
        }, 
        "id": "p54084", 
        "name": "Selection", 
        "type": "object"
      }, 
      "selection_policy": {
        "id": "p54085", 
        "name": "UnionRenderers", 
        "type": "object"
      }
    }, 
    "id": "p54083", 
    "name": "ColumnDataSource", 
    "type": "object"
  }, 
  "styles": {
    "type": "map"
  }, 
  "stylesheets": [], 
  "subscribed_events": {
    "type": "set"
  }, 
  "syncable": true, 
  "tags": [], 
  "upper": {
    "field": "upper", 
    "type": "field"
  }, 
  "upper_head": {
    "attributes": {
      "size": {
        "type": "value", 
        "value": 10
      }
    }, 
    "id": "p54087", 
    "name": "TeeHead", 
    "type": "object"
  }, 
  "visible": true, 
  "x_range_name": "default", 
  "y_range_name": "default"
}
base = Field(field='base', transform=Unspecified, units=Unspecified)#
Type:

UnitsSpec

The orthogonal coordinates of the upper and lower values.

base_units = 'data'#
Type:

NotSerialized(Enum(CoordinateUnits))

Units to use for the associated property: canvas, screen or data

context_menu = None#
Type:

Nullable(Instance(‘.models.ui.Menu’))

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes = []#
Type:

List

A list of additional CSS classes to add to the underlying DOM element.

css_variables = {}#
Type:

Dict(String, Instance(Node))

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

dimension = 'height'#
Type:

Enum(Dimension)

The direction of the whisker can be specified by setting this property to “height” (y direction) or “width” (x direction).

elements = []#
Type:

List

A collection of DOM-based UI elements attached to this renderer.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this renderer and its UI elements.

Note

This property is an equivalent of Pane.elements in DOM-based UIs.

group = None#
Type:

Nullable(Instance(RendererGroup))

Note

This property is experimental and may change at any point.

level = 'underlay'#
Type:

Enum(RenderLevel)

Specifies the level in which to paint this renderer.

line_alpha = 1.0#
Type:

AlphaSpec

The line alpha values for the whisker body.

line_cap = 'butt'#
Type:

LineCapSpec

The line cap values for the whisker body.

line_color = 'black'#
Type:

ColorSpec

The line color values for the whisker body.

line_dash = []#
Type:

DashPatternSpec

The line dash values for the whisker body.

line_dash_offset = 0#
Type:

IntSpec

The line dash offset values for the whisker body.

line_join = 'bevel'#
Type:

LineJoinSpec

The line join values for the whisker body.

line_width = 1#
Type:

NumberSpec

The line width values for the whisker body.

lower = Field(field='lower', transform=Unspecified, units=Unspecified)#
Type:

UnitsSpec

The coordinates of the lower end of the whiskers.

lower_head = TeeHead(id='p54196', ...)#
Type:

Nullable(Instance(ArrowHead))

Instance of ArrowHead.

lower_units = 'data'#
Type:

NotSerialized(Enum(CoordinateUnits))

Units to use for the associated property: canvas, screen or data

name = None#
Type:

Nullable(String)

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

propagate_hover = False#
Type:

Bool

Allows to propagate hover events to the parent renderer, frame or canvas.

Note

This property is experimental and may change at any point.

renderers = []#
Type:

List

A collection of renderers attached to this renderer.

Note

This property is experimental and may change at any point.

source = ColumnDataSource(id='p54227', ...)#
Type:

Instance(DataSource)

Local data source to use when rendering annotations on the plot.

styles = {}#
Type:

Either(Dict(String, Nullable(String)), Instance(Styles))

Inline CSS styles applied to the underlying DOM element.

stylesheets = []#
Type:

List

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

syncable = True#
Type:

Bool

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags = []#
Type:

List

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

upper = Field(field='upper', transform=Unspecified, units=Unspecified)#
Type:

UnitsSpec

The coordinates of the upper end of the whiskers.

upper_head = TeeHead(id='p54266', ...)#
Type:

Nullable(Instance(ArrowHead))

Instance of ArrowHead.

upper_units = 'data'#
Type:

NotSerialized(Enum(CoordinateUnits))

Units to use for the associated property: canvas, screen or data

visible = True#
Type:

Bool

Is the renderer visible.

x_range_name = 'default'#
Type:

String

A particular (named) x-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default x-range.

y_range_name = 'default'#
Type:

String

A particular (named) y-range to use for computing screen locations when rendering glyphs on the plot. If unset, use the default y-range.

apply_theme(property_values: dict[str, Any]) None#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[PropertyDescriptor[Any]]#

List of property descriptors in the order of definition.

destroy() None#

Clean up references to the document and property

equals(other: HasProps) bool#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (int | str) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
classmethod lookup(name: str, *, raises: bool = True) PropertyDescriptor[Any] | None#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

on_change(attr: str, *callbacks: PropertyCallback) None#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[Event], *callbacks: Callable[[Event], None] | Callable[[], None]) None#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[Parameter]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any]#

Query the properties values of HasProps instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[Model]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like)

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like)

  • updates (dict)

Returns:

None

themed_values() dict[str, Any] | None#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None#
unapply_theme() None#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
property document: Document | None#

The Document this model is attached to (can be None)