annotations#
Renderers for various kinds of annotations that can be added to plots.
- class Annotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
RendererBase 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
{ "coordinates": null, "group": null, "id": "p114474", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Public Data Attributes:
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Arrow(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
DataAnnotationRender arrows as an annotation.
See Arrows for information on plotting arrows.
JSON Prototype
{ "coordinates": null, "end": { "id": "p114486", "name": "OpenHead", "type": "object" }, "end_units": "data", "group": null, "id": "p114482", "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, "source": { "attributes": { "data": { "type": "map" }, "selected": { "attributes": { "indices": [], "line_indices": [] }, "id": "p114485", "name": "Selection", "type": "object" }, "selection_policy": { "id": "p114484", "name": "UnionRenderers", "type": "object" } }, "id": "p114483", "name": "ColumnDataSource", "type": "object" }, "start": null, "start_units": "data", "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" } }
Public Data Attributes:
x_startThe x-coordinates to locate the start of the arrows.
y_startThe y-coordinates to locate the start of the arrows.
start_unitsThe unit type for the start_x and start_y attributes.
startInstance of
ArrowHead.x_endThe x-coordinates to locate the end of the arrows.
y_endThe y-coordinates to locate the end of the arrows.
end_unitsThe unit type for the end_x and end_y attributes.
endInstance of
ArrowHead.line_colorThe line color values for the arrow body.
line_alphaThe line alpha values for the arrow body.
line_widthThe line width values for the arrow body.
line_joinThe line join values for the arrow body.
line_capThe line cap values for the arrow body.
line_dashThe line dash values for the arrow body.
line_dash_offsetThe line dash offset values for the arrow body.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
DataAnnotationsourceLocal data source to use when rendering annotations on the plot.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, end, end_units, group, level, ...])Inherited from
DataAnnotation__init__(*[, group, level, name, source, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- end_units = 'data'#
- Type:
The unit type for the end_x and end_y attributes. Interpreted as “data space” units by default.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the arrow body.
- name = None#
-
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.
- source = ColumnDataSource(id='p114554', ...)#
- Type:
Local data source to use when rendering annotations on the plot.
- start_units = 'data'#
- Type:
The unit type for the start_x and start_y attributes. Interpreted as “data space” units by default.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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.
- x_end = Field(field='x_end', transform=Unspecified, units=Unspecified)#
- Type:
The x-coordinates to locate the end of the arrows.
- x_range_name = 'default'#
- Type:
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:
The x-coordinates to locate the start of the arrows.
- y_end = Field(field='y_end', transform=Unspecified, units=Unspecified)#
- Type:
The y-coordinates to locate the end of the arrows.
- y_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class ArrowHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
MarkingBase 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": "p114612", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "name": null, "size": { "type": "value", "value": 25 }, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [] }
Public Data Attributes:
sizeThe size, in pixels, of the arrow head.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
MarkingnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, size, syncable, tags])Inherited from
Marking__init__(*[, syncable, tags])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- name = None#
-
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:
The size, in pixels, of the arrow head.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Band(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
DataAnnotationRender a filled area band along a dimension.
See Bands for information on plotting bands.
JSON Prototype
{ "base": { "field": "base", "type": "field" }, "coordinates": null, "dimension": "height", "fill_alpha": 0.4, "fill_color": "#fff9ba", "group": null, "id": "p114617", "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, "source": { "attributes": { "data": { "type": "map" }, "selected": { "attributes": { "indices": [], "line_indices": [] }, "id": "p114620", "name": "Selection", "type": "object" }, "selection_policy": { "id": "p114619", "name": "UnionRenderers", "type": "object" } }, "id": "p114618", "name": "ColumnDataSource", "type": "object" }, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "upper": { "field": "upper", "type": "field" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
Public Data Attributes:
lower_unitsUnits to use for the associated property: canvas, screen or data
lowerThe coordinates of the lower portion of the filled area band.
upper_unitsUnits to use for the associated property: canvas, screen or data
upperThe coordinates of the upper portion of the filled area band.
base_unitsUnits to use for the associated property: canvas, screen or data
baseThe orthogonal coordinates of the upper and lower values.
dimensionThe direction of the band can be specified by setting this property to "height" (
ydirection) or "width" (xdirection).line_colorThe line color values for the band.
line_alphaThe line alpha values for the band.
line_widthThe line width values for the band.
line_joinThe line join values for the band.
line_capThe line cap values for the band.
line_dashThe line dash values for the band.
line_dash_offsetThe line dash offset values for the band.
fill_colorThe fill color values for the band.
fill_alphaThe fill alpha values for the band.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
DataAnnotationsourceLocal data source to use when rendering annotations on the plot.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, base_units, coordinates, ...])Inherited from
DataAnnotation__init__(*[, group, level, name, source, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- base = Field(field='base', transform=Unspecified, units=Unspecified)#
- Type:
The orthogonal coordinates of the upper and lower values.
- base_units = 'data'#
- Type:
Units to use for the associated property: canvas, screen or data
- dimension = 'height'#
-
The direction of the band can be specified by setting this property to “height” (
ydirection) or “width” (xdirection).
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- line_dash = []#
- Type:
The line dash values for the band.
- lower = Field(field='lower', transform=Unspecified, units=Unspecified)#
- Type:
The coordinates of the lower portion of the filled area band.
- lower_units = 'data'#
- Type:
Units to use for the associated property: canvas, screen or data
- name = None#
-
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.
- source = ColumnDataSource(id='p114694', ...)#
- Type:
Local data source to use when rendering annotations on the plot.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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:
The coordinates of the upper portion of the filled area band.
- upper_units = 'data'#
- Type:
Units to use for the associated property: canvas, screen or data
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class BoxAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
AnnotationRender a shaded rectangular region as an annotation.
See Box annotations for information on plotting box annotations.
JSON Prototype
{ "bottom": null, "bottom_units": "data", "coordinates": null, "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, "id": "p114725", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "left": 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, "name": null, "right": null, "right_units": "data", "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "top": null, "top_units": "data", "visible": true, "x_range_name": "default", "y_range_name": "default" }
Public Data Attributes:
leftThe x-coordinates of the left edge of the box annotation.
left_unitsThe unit type for the left attribute.
rightThe x-coordinates of the right edge of the box annotation.
right_unitsThe unit type for the right attribute.
bottomThe y-coordinates of the bottom edge of the box annotation.
bottom_unitsThe unit type for the bottom attribute.
topThe y-coordinates of the top edge of the box annotation.
top_unitsThe unit type for the top attribute.
line_colorThe line color values for the box.
line_alphaThe line alpha values for the box.
line_widthThe line width values for the box.
line_joinThe line join values for the box.
line_capThe line cap values for the box.
line_dashThe line dash values for the box.
line_dash_offsetThe line dash offset values for the box.
fill_colorThe fill color values for the box.
fill_alphaThe fill alpha values for the box.
hatch_colorThe hatch color values for the box.
hatch_alphaThe hatch alpha values for the box.
hatch_scaleThe hatch scale values for the box.
hatch_patternThe hatch pattern values for the box.
hatch_weightThe hatch weight values for the box.
hatch_extraThe hatch extra values for the box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, bottom_units, coordinates, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- bottom = None#
-
The y-coordinates of the bottom edge of the box annotation.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- bottom_units = 'data'#
- Type:
The unit type for the bottom attribute. Interpreted as data units by default.
- left = None#
-
The x-coordinates of the left edge of the box annotation.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- left_units = 'data'#
- Type:
The unit type for the left attribute. Interpreted as data units by default.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- line_dash = []#
- Type:
The line dash values for the box.
- name = None#
-
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.
- right = None#
-
The x-coordinates of the right edge of the box annotation.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- right_units = 'data'#
- Type:
The unit type for the right attribute. Interpreted as data units by default.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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 = None#
-
The y-coordinates of the top edge of the box annotation.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- top_units = 'data'#
- Type:
The unit type for the top attribute. Interpreted as data units by default.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class ColorBar(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
BaseColorBarRender 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, "coordinates": null, "display_high": null, "display_low": null, "formatter": "auto", "group": null, "height": "auto", "id": "p114756", "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": "p114757", "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, "scale_alpha": 1.0, "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" }
Public Data Attributes:
color_mapperA color mapper containing a color palette to render.
display_lowThe lowest value to display in the color bar.
display_highThe highest value to display in the color bar.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
BaseColorBarlocationThe location where the color bar should draw itself.
orientationWhether the color bar should be oriented vertically or horizontally.
heightThe height (in pixels) that the color scale should occupy.
widthThe width (in pixels) that the color scale should occupy.
scale_alphaThe alpha with which to render the color scale.
titleThe title text to render.
title_text_colorThe text color values for the title text.
title_text_outline_colorThe text outline color values for the title text.
title_text_alphaThe text alpha values for the title text.
title_text_fontThe text font values for the title text.
title_text_font_sizeThe text font size values for the title text.
title_text_font_styleThe text font style values for the title text.
title_text_alignThe text align values for the title text.
title_text_baselineThe text baseline values for the title text.
title_text_line_heightThe text line height values for the title text.
title_standoffThe distance (in pixels) to separate the title from the color bar.
tickerA Ticker to use for computing locations of axis components.
formatterA
TickFormatterto use for formatting the visual appearance of ticks.major_label_overridesProvide explicit tick label values for specific tick locations that override normal formatting.
major_label_policyAllows to filter out labels, e.g.
marginAmount of margin (in pixels) around the outside of the color bar.
paddingAmount of padding (in pixels) between the color scale and color bar border.
major_label_text_colorThe text color of the major tick labels.
major_label_text_outline_colorThe text outline color of the major tick labels.
major_label_text_alphaThe text alpha of the major tick labels.
major_label_text_fontThe text font of the major tick labels.
major_label_text_font_sizeThe text font size of the major tick labels.
major_label_text_font_styleThe text font style of the major tick labels.
major_label_text_alignThe text align of the major tick labels.
major_label_text_baselineThe text baseline of the major tick labels.
major_label_text_line_heightThe text line height of the major tick labels.
label_standoffThe distance (in pixels) to separate the tick labels from the color bar.
major_tick_line_colorThe line color of the major ticks.
major_tick_line_alphaThe line alpha of the major ticks.
major_tick_line_widthThe line width of the major ticks.
major_tick_line_joinThe line join of the major ticks.
major_tick_line_capThe line cap of the major ticks.
major_tick_line_dashThe line dash of the major ticks.
major_tick_line_dash_offsetThe line dash offset of the major ticks.
major_tick_inThe distance (in pixels) that major ticks should extend into the main plot area.
major_tick_outThe distance (in pixels) that major ticks should extend out of the main plot area.
minor_tick_line_colorThe line color of the minor ticks.
minor_tick_line_alphaThe line alpha of the minor ticks.
minor_tick_line_widthThe line width of the minor ticks.
minor_tick_line_joinThe line join of the minor ticks.
minor_tick_line_capThe line cap of the minor ticks.
minor_tick_line_dashThe line dash of the minor ticks.
minor_tick_line_dash_offsetThe line dash offset of the minor ticks.
minor_tick_inThe distance (in pixels) that minor ticks should extend into the main plot area.
minor_tick_outThe distance (in pixels) that major ticks should extend out of the main plot area.
bar_line_colorThe line color for the color scale bar outline.
bar_line_alphaThe line alpha for the color scale bar outline.
bar_line_widthThe line width for the color scale bar outline.
bar_line_joinThe line join for the color scale bar outline.
bar_line_capThe line cap for the color scale bar outline.
bar_line_dashThe line dash for the color scale bar outline.
bar_line_dash_offsetThe line dash offset for the color scale bar outline.
border_line_colorThe line color for the color bar border outline.
border_line_alphaThe line alpha for the color bar border outline.
border_line_widthThe line width for the color bar border outline.
border_line_joinThe line join for the color bar border outline.
border_line_capThe line cap for the color bar border outline.
border_line_dashThe line dash for the color bar border outline.
border_line_dash_offsetThe line dash offset for the color bar border outline.
background_fill_colorThe fill color for the color bar background style.
background_fill_alphaThe fill alpha for the color bar background style.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, background_fill_color, ...])Inherited from
BaseColorBar__init__(*[, background_fill_color, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- background_fill_color = '#ffffff'#
-
The fill color for the color bar background style.
- bar_line_dash = []#
- Type:
The line dash for the color scale bar outline.
- border_line_dash = []#
- Type:
The line dash for the color bar border outline.
- color_mapper = Undefined#
- Type:
A color mapper containing a color palette to render.
Warning
If the low and high attributes of the
ColorMapperaren’t set, ticks and tick labels won’t be rendered. Additionally, if aLogTickeris 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.
- display_high = None#
-
The highest value to display in the color bar. The whole of the color entry containing this value is shown.
- display_low = None#
-
The lowest value to display in the color bar. The whole of the color entry containing this value is shown.
- formatter = 'auto'#
- Type:
A
TickFormatterto use for formatting the visual appearance of ticks.
- label_standoff = 5#
- Type:
The distance (in pixels) to separate the tick labels from the color bar.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- location = 'top_right'#
-
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 = {}#
-
Provide explicit tick label values for specific tick locations that override normal formatting.
- major_label_policy = NoOverlap(id='p114811', ...)#
- Type:
Instance(LabelingPolicy)
Allows to filter out labels, e.g. declutter labels to avoid overlap.
- major_label_text_baseline = 'bottom'#
- Type:
The text baseline of the major tick labels.
- major_label_text_font_style = 'normal'#
-
The text font style of the major tick labels.
- major_label_text_outline_color = None#
-
The text outline color of the major tick labels.
- major_tick_in = 5#
- Type:
The distance (in pixels) that major ticks should extend into the main plot area.
- major_tick_line_dash = []#
- Type:
The line dash of the major ticks.
- major_tick_out = 0#
- Type:
The distance (in pixels) that major ticks should extend out of the main plot area.
- minor_tick_in = 0#
- Type:
The distance (in pixels) that minor ticks should extend into the main plot area.
- minor_tick_line_dash = []#
- Type:
The line dash of the minor ticks.
- minor_tick_out = 0#
- Type:
The distance (in pixels) that major ticks should extend out of the main plot area.
- name = None#
-
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:
Whether the color bar should be oriented vertically or horizontally.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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'#
-
A Ticker to use for computing locations of axis components.
- title_text_baseline = 'bottom'#
- Type:
The text baseline values for the title text.
- title_text_font_style = 'italic'#
-
The text font style values for the title text.
- title_text_outline_color = None#
-
The text outline color values for the title text.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class ContourColorBar(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
BaseColorBarColor 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, "coordinates": null, "formatter": "auto", "group": null, "height": "auto", "id": "p114912", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "label_standoff": 5, "level": "annotation", "levels": [], "location": "top_right", "major_label_overrides": { "type": "map" }, "major_label_policy": { "id": "p114913", "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, "scale_alpha": 1.0, "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" }
Public Data Attributes:
fill_rendererGlyph renderer used for filled contour polygons.
line_rendererGlyph renderer used for contour lines.
levelsLevels at which the contours are calculated.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
BaseColorBarlocationThe location where the color bar should draw itself.
orientationWhether the color bar should be oriented vertically or horizontally.
heightThe height (in pixels) that the color scale should occupy.
widthThe width (in pixels) that the color scale should occupy.
scale_alphaThe alpha with which to render the color scale.
titleThe title text to render.
title_text_colorThe text color values for the title text.
title_text_outline_colorThe text outline color values for the title text.
title_text_alphaThe text alpha values for the title text.
title_text_fontThe text font values for the title text.
title_text_font_sizeThe text font size values for the title text.
title_text_font_styleThe text font style values for the title text.
title_text_alignThe text align values for the title text.
title_text_baselineThe text baseline values for the title text.
title_text_line_heightThe text line height values for the title text.
title_standoffThe distance (in pixels) to separate the title from the color bar.
tickerA Ticker to use for computing locations of axis components.
formatterA
TickFormatterto use for formatting the visual appearance of ticks.major_label_overridesProvide explicit tick label values for specific tick locations that override normal formatting.
major_label_policyAllows to filter out labels, e.g.
marginAmount of margin (in pixels) around the outside of the color bar.
paddingAmount of padding (in pixels) between the color scale and color bar border.
major_label_text_colorThe text color of the major tick labels.
major_label_text_outline_colorThe text outline color of the major tick labels.
major_label_text_alphaThe text alpha of the major tick labels.
major_label_text_fontThe text font of the major tick labels.
major_label_text_font_sizeThe text font size of the major tick labels.
major_label_text_font_styleThe text font style of the major tick labels.
major_label_text_alignThe text align of the major tick labels.
major_label_text_baselineThe text baseline of the major tick labels.
major_label_text_line_heightThe text line height of the major tick labels.
label_standoffThe distance (in pixels) to separate the tick labels from the color bar.
major_tick_line_colorThe line color of the major ticks.
major_tick_line_alphaThe line alpha of the major ticks.
major_tick_line_widthThe line width of the major ticks.
major_tick_line_joinThe line join of the major ticks.
major_tick_line_capThe line cap of the major ticks.
major_tick_line_dashThe line dash of the major ticks.
major_tick_line_dash_offsetThe line dash offset of the major ticks.
major_tick_inThe distance (in pixels) that major ticks should extend into the main plot area.
major_tick_outThe distance (in pixels) that major ticks should extend out of the main plot area.
minor_tick_line_colorThe line color of the minor ticks.
minor_tick_line_alphaThe line alpha of the minor ticks.
minor_tick_line_widthThe line width of the minor ticks.
minor_tick_line_joinThe line join of the minor ticks.
minor_tick_line_capThe line cap of the minor ticks.
minor_tick_line_dashThe line dash of the minor ticks.
minor_tick_line_dash_offsetThe line dash offset of the minor ticks.
minor_tick_inThe distance (in pixels) that minor ticks should extend into the main plot area.
minor_tick_outThe distance (in pixels) that major ticks should extend out of the main plot area.
bar_line_colorThe line color for the color scale bar outline.
bar_line_alphaThe line alpha for the color scale bar outline.
bar_line_widthThe line width for the color scale bar outline.
bar_line_joinThe line join for the color scale bar outline.
bar_line_capThe line cap for the color scale bar outline.
bar_line_dashThe line dash for the color scale bar outline.
bar_line_dash_offsetThe line dash offset for the color scale bar outline.
border_line_colorThe line color for the color bar border outline.
border_line_alphaThe line alpha for the color bar border outline.
border_line_widthThe line width for the color bar border outline.
border_line_joinThe line join for the color bar border outline.
border_line_capThe line cap for the color bar border outline.
border_line_dashThe line dash for the color bar border outline.
border_line_dash_offsetThe line dash offset for the color bar border outline.
background_fill_colorThe fill color for the color bar background style.
background_fill_alphaThe fill alpha for the color bar background style.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, background_fill_color, ...])Inherited from
BaseColorBar__init__(*[, background_fill_color, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- background_fill_color = '#ffffff'#
-
The fill color for the color bar background style.
- bar_line_dash = []#
- Type:
The line dash for the color scale bar outline.
- border_line_dash = []#
- Type:
The line dash for the color bar border outline.
- fill_renderer = Undefined#
- Type:
Glyph renderer used for filled contour polygons.
- formatter = 'auto'#
- Type:
A
TickFormatterto use for formatting the visual appearance of ticks.
- label_standoff = 5#
- Type:
The distance (in pixels) to separate the tick labels from the color bar.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- line_renderer = Undefined#
- Type:
Glyph renderer used for contour lines.
- location = 'top_right'#
-
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 = {}#
-
Provide explicit tick label values for specific tick locations that override normal formatting.
- major_label_policy = NoOverlap(id='p114967', ...)#
- Type:
Instance(LabelingPolicy)
Allows to filter out labels, e.g. declutter labels to avoid overlap.
- major_label_text_baseline = 'bottom'#
- Type:
The text baseline of the major tick labels.
- major_label_text_font_style = 'normal'#
-
The text font style of the major tick labels.
- major_label_text_outline_color = None#
-
The text outline color of the major tick labels.
- major_tick_in = 5#
- Type:
The distance (in pixels) that major ticks should extend into the main plot area.
- major_tick_line_dash = []#
- Type:
The line dash of the major ticks.
- major_tick_out = 0#
- Type:
The distance (in pixels) that major ticks should extend out of the main plot area.
- minor_tick_in = 0#
- Type:
The distance (in pixels) that minor ticks should extend into the main plot area.
- minor_tick_line_dash = []#
- Type:
The line dash of the minor ticks.
- minor_tick_out = 0#
- Type:
The distance (in pixels) that major ticks should extend out of the main plot area.
- name = None#
-
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:
Whether the color bar should be oriented vertically or horizontally.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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'#
-
A Ticker to use for computing locations of axis components.
- title_text_baseline = 'bottom'#
- Type:
The text baseline values for the title text.
- title_text_font_style = 'italic'#
-
The text font style values for the title text.
- title_text_outline_color = None#
-
The text outline color values for the title text.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class HTMLAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
AnnotationBase 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
{ "coordinates": null, "group": null, "id": "p115068", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Public Data Attributes:
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, group, level, name, syncable, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class HTMLLabel(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
HTMLAnnotationRender a single HTML label as an annotation.
Labelwill render a single text label at givenxandycoordinates, 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
xandy, by using thex_offsetandy_offsetproperties.Additionally, the label can be rotated with the
angleproperty.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, "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, "coordinates": null, "group": null, "id": "p115076", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "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_offset": 0, "x_range_name": "default", "x_units": "data", "y_offset": 0, "y_range_name": "default", "y_units": "data" }
Public Data Attributes:
xThe x-coordinate in screen coordinates to locate the text anchors.
x_unitsThe unit type for the x attribute.
yThe y-coordinate in screen coordinates to locate the text anchors.
y_unitsThe unit type for the y attribute.
textThe text value to render.
angleThe angle to rotate the text, as measured from the horizontal.
angle_unitsAcceptable values for units are
"rad"and"deg"x_offsetOffset value to apply to the x-coordinate.
y_offsetOffset value to apply to the y-coordinate.
text_colorThe text color values for the text.
text_outline_colorThe text outline color values for the text.
text_alphaThe text alpha values for the text.
text_fontThe text font values for the text.
text_font_sizeThe text font size values for the text.
text_font_styleThe text font style values for the text.
text_alignThe text align values for the text.
text_baselineThe text baseline values for the text.
text_line_heightThe text line height values for the text.
background_fill_colorThe fill color values for the text bounding box.
background_fill_alphaThe fill alpha values for the text bounding box.
border_line_colorThe line color values for the text bounding box.
border_line_alphaThe line alpha values for the text bounding box.
border_line_widthThe line width values for the text bounding box.
border_line_joinThe line join values for the text bounding box.
border_line_capThe line cap values for the text bounding box.
border_line_dashThe line dash values for the text bounding box.
border_line_dash_offsetThe line dash offset values for the text bounding box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
HTMLAnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, angle_units, ...])Inherited from
HTMLAnnotation__init__(*[, group, level, name, syncable, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- angle_units = 'rad'#
- Type:
Acceptable values for units are
"rad"and"deg"
- background_fill_color = None#
-
The fill color values for the text bounding box.
- border_line_dash = []#
- Type:
The line dash values for the text bounding box.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_baseline = 'bottom'#
- Type:
The text baseline values for the text.
- x = Undefined#
-
The x-coordinate in screen coordinates to locate the text anchors.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- x_offset = 0#
- Type:
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:
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:
The unit type for the x attribute. Interpreted as data units by default.
- y = Undefined#
-
The y-coordinate in screen coordinates to locate the text anchors.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- y_offset = 0#
- Type:
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:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class HTMLLabelSet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
HTMLAnnotation,DataAnnotationRender multiple text labels as annotations.
LabelSetwill render multiple text labels at givenxandycoordinates, which can be in either screen (pixel) space, or data (axis range) space. In this case (as opposed to the singleLabelmodel),xandycan also be the name of a column from aColumnDataSource, 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
xandy, by using thex_offsetandy_offsetproperties. These offsets may be vectorized by giving the name of a data source column.Additionally, the label can be rotated with the
angleproperty (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
sourceproperty.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 }, "coordinates": null, "group": null, "id": "p115111", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "source": { "attributes": { "data": { "type": "map" }, "selected": { "attributes": { "indices": [], "line_indices": [] }, "id": "p115114", "name": "Selection", "type": "object" }, "selection_policy": { "id": "p115113", "name": "UnionRenderers", "type": "object" } }, "id": "p115112", "name": "ColumnDataSource", "type": "object" }, "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" }
Public Data Attributes:
xThe x-coordinates to locate the text anchors.
x_unitsThe unit type for the
xsattribute.yThe y-coordinates to locate the text anchors.
y_unitsThe unit type for the
ysattribute.textThe text values to render.
angle_unitsUnits to use for the associated property: deg, rad, grad or turn
angleThe angles to rotate the text, as measured from the horizontal.
x_offsetOffset values to apply to the x-coordinates.
y_offsetOffset values to apply to the y-coordinates.
text_colorThe text color values for the text.
text_outline_colorThe text outline color values for the text.
text_alphaThe text alpha values for the text.
text_fontThe text font values for the text.
text_font_sizeThe text font size values for the text.
text_font_styleThe text font style values for the text.
text_alignThe text align values for the text.
text_baselineThe text baseline values for the text.
text_line_heightThe text line height values for the text.
background_fill_colorThe fill color values for the text bounding box.
background_fill_alphaThe fill alpha values for the text bounding box.
border_line_colorThe line color values for the text bounding box.
border_line_alphaThe line alpha values for the text bounding box.
border_line_widthThe line width values for the text bounding box.
border_line_joinThe line join values for the text bounding box.
border_line_capThe line cap values for the text bounding box.
border_line_dashThe line dash values for the text bounding box.
border_line_dash_offsetThe line dash offset values for the text bounding box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
HTMLAnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
DataAnnotationsourceLocal data source to use when rendering annotations on the plot.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, angle_units, ...])Inherited from
HTMLAnnotation__init__(*[, group, level, name, syncable, ...])Inherited from
DataAnnotation__init__(*[, group, level, name, source, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- angle_units = 'rad'#
- Type:
Units to use for the associated property: deg, rad, grad or turn
- border_line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the text bounding box.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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.
- source = ColumnDataSource(id='p115176', ...)#
- Type:
Local data source to use when rendering annotations on the plot.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_baseline = 'bottom'#
- Type:
TextBaselineSpec
The text baseline values for the text.
- text_font = Value(value='helvetica', transform=Unspecified, units=Unspecified)#
- Type:
The text font values for the text.
- text_font_size = Value(value='16px', transform=Unspecified, units=Unspecified)#
- Type:
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:
The text line height values for the text.
- x = Field(field='x', transform=Unspecified, units=Unspecified)#
- Type:
The x-coordinates to locate the text anchors.
- x_offset = 0#
- Type:
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:
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:
The unit type for the
xsattribute. Interpreted as data units by default.
- y = Field(field='y', transform=Unspecified, units=Unspecified)#
- Type:
The y-coordinates to locate the text anchors.
- y_offset = 0#
- Type:
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:
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:
The unit type for the
ysattribute. 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class HTMLTitle(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
HTMLAnnotationRender 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, "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, "coordinates": null, "group": null, "id": "p115263", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "offset": 0, "standoff": 10, "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" }
Public Data Attributes:
textThe text value to render.
vertical_alignAlignment of the text in its enclosing space, across the direction of the text.
alignAlignment of the text in its enclosing space, along the direction of the text.
text_line_heightHow much additional space should be allocated for the title.
offsetOffset the text by a number of pixels (can be positive or negative).
standofftext_fontName of a font to use for rendering text, e.g.,
'times','helvetica'.text_font_sizetext_font_styleA style to use for rendering text.
text_colorA color to use to fill text with.
text_outline_colorA color to use to fill text with.
text_alphaAn alpha value to use to fill text with.
background_fill_colorThe fill color values for the text bounding box.
background_fill_alphaThe fill alpha values for the text bounding box.
border_line_colorThe line color values for the text bounding box.
border_line_alphaThe line alpha values for the text bounding box.
border_line_widthThe line width values for the text bounding box.
border_line_joinThe line join values for the text bounding box.
border_line_capThe line cap values for the text bounding box.
border_line_dashThe line dash values for the text bounding box.
border_line_dash_offsetThe line dash offset values for the text bounding box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
HTMLAnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, background_fill_alpha, ...])Inherited from
HTMLAnnotation__init__(*[, group, level, name, syncable, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- align = 'left'#
-
Alignment of the text in its enclosing space, along the direction of the text.
- background_fill_color = None#
-
The fill color values for the text bounding box.
- border_line_dash = []#
- Type:
The line dash values for the text bounding box.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
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
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_alpha = 1.0#
- Type:
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:
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:
Name of a font to use for rendering text, e.g.,
'times','helvetica'.
- text_font_style = 'bold'#
-
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:
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.
- vertical_align = 'bottom'#
- Type:
Alignment of the text in its enclosing space, across the direction of the text.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Label(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
TextAnnotationRender a single text label as an annotation.
Labelwill render a single text label at givenxandycoordinates, 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
xandy, by using thex_offsetandy_offsetproperties.Additionally, the label can be rotated with the
angleproperty.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, "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, "coordinates": null, "group": null, "id": "p115291", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "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_offset": 0, "x_range_name": "default", "x_units": "data", "y_offset": 0, "y_range_name": "default", "y_units": "data" }
Public Data Attributes:
xThe x-coordinate in screen coordinates to locate the text anchors.
x_unitsThe unit type for the x attribute.
yThe y-coordinate in screen coordinates to locate the text anchors.
y_unitsThe unit type for the y attribute.
angleThe angle to rotate the text, as measured from the horizontal.
angle_unitsAcceptable values for units are
"rad"and"deg"x_offsetOffset value to apply to the x-coordinate.
y_offsetOffset value to apply to the y-coordinate.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
TextAnnotationtextA text or LaTeX notation to render.
text_colorThe text color values for the text.
text_outline_colorThe text outline color values for the text.
text_alphaThe text alpha values for the text.
text_fontThe text font values for the text.
text_font_sizeThe text font size values for the text.
text_font_styleThe text font style values for the text.
text_alignThe text align values for the text.
text_baselineThe text baseline values for the text.
text_line_heightThe text line height values for the text.
background_fill_colorThe fill color values for the text bounding box.
background_fill_alphaThe fill alpha values for the text bounding box.
border_line_colorThe line color values for the text bounding box.
border_line_alphaThe line alpha values for the text bounding box.
border_line_widthThe line width values for the text bounding box.
border_line_joinThe line join values for the text bounding box.
border_line_capThe line cap values for the text bounding box.
border_line_dashThe line dash values for the text bounding box.
border_line_dash_offsetThe line dash offset values for the text bounding box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, angle_units, ...])Inherited from
TextAnnotation__init__(*[, background_fill_color, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- angle_units = 'rad'#
- Type:
Acceptable values for units are
"rad"and"deg"
- background_fill_color = None#
-
The fill color values for the text bounding box.
- border_line_dash = []#
- Type:
The line dash values for the text bounding box.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_baseline = 'bottom'#
- Type:
The text baseline values for the text.
- x = Undefined#
-
The x-coordinate in screen coordinates to locate the text anchors.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- x_offset = 0#
- Type:
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:
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:
The unit type for the x attribute. Interpreted as data units by default.
- y = Undefined#
-
The y-coordinate in screen coordinates to locate the text anchors.
Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- y_offset = 0#
- Type:
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:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class LabelSet(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
DataAnnotationRender multiple text labels as annotations.
LabelSetwill render multiple text labels at givenxandycoordinates, which can be in either screen (pixel) space, or data (axis range) space. In this case (as opposed to the singleLabelmodel),xandycan also be the name of a column from aColumnDataSource, 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
xandy, by using thex_offsetandy_offsetproperties. These offsets may be vectorized by giving the name of a data source column.Additionally, the label can be rotated with the
angleproperty (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
sourceproperty.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 }, "coordinates": null, "group": null, "id": "p115326", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "source": { "attributes": { "data": { "type": "map" }, "selected": { "attributes": { "indices": [], "line_indices": [] }, "id": "p115329", "name": "Selection", "type": "object" }, "selection_policy": { "id": "p115328", "name": "UnionRenderers", "type": "object" } }, "id": "p115327", "name": "ColumnDataSource", "type": "object" }, "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" }
Public Data Attributes:
xThe x-coordinates to locate the text anchors.
x_unitsThe unit type for the
xsattribute.yThe y-coordinates to locate the text anchors.
y_unitsThe unit type for the
ysattribute.textThe text values to render.
angle_unitsUnits to use for the associated property: deg, rad, grad or turn
angleThe angles to rotate the text, as measured from the horizontal.
x_offsetOffset values to apply to the x-coordinates.
y_offsetOffset values to apply to the y-coordinates.
text_colorThe text color values for the text.
text_outline_colorThe text outline color values for the text.
text_alphaThe text alpha values for the text.
text_fontThe text font values for the text.
text_font_sizeThe text font size values for the text.
text_font_styleThe text font style values for the text.
text_alignThe text align values for the text.
text_baselineThe text baseline values for the text.
text_line_heightThe text line height values for the text.
background_fill_colorThe fill color values for the text bounding box.
background_fill_alphaThe fill alpha values for the text bounding box.
border_line_colorThe line color values for the text bounding box.
border_line_alphaThe line alpha values for the text bounding box.
border_line_widthThe line width values for the text bounding box.
border_line_joinThe line join values for the text bounding box.
border_line_capThe line cap values for the text bounding box.
border_line_dashThe line dash values for the text bounding box.
border_line_dash_offsetThe line dash offset values for the text bounding box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
DataAnnotationsourceLocal data source to use when rendering annotations on the plot.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, angle_units, ...])Inherited from
DataAnnotation__init__(*[, group, level, name, source, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- angle_units = 'rad'#
- Type:
Units to use for the associated property: deg, rad, grad or turn
- border_line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the text bounding box.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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.
- source = ColumnDataSource(id='p115391', ...)#
- Type:
Local data source to use when rendering annotations on the plot.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_baseline = 'bottom'#
- Type:
TextBaselineSpec
The text baseline values for the text.
- text_font = Value(value='helvetica', transform=Unspecified, units=Unspecified)#
- Type:
The text font values for the text.
- text_font_size = Value(value='16px', transform=Unspecified, units=Unspecified)#
- Type:
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:
The text line height values for the text.
- x = Field(field='x', transform=Unspecified, units=Unspecified)#
- Type:
The x-coordinates to locate the text anchors.
- x_offset = 0#
- Type:
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:
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:
The unit type for the
xsattribute. Interpreted as data units by default.
- y = Field(field='y', transform=Unspecified, units=Unspecified)#
- Type:
The y-coordinates to locate the text anchors.
- y_offset = 0#
- Type:
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:
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:
The unit type for the
ysattribute. 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Legend(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
AnnotationRender 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", "coordinates": null, "glyph_height": 20, "glyph_width": 20, "group": null, "id": "p115478", "inactive_fill_alpha": 0.7, "inactive_fill_color": "white", "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, "orientation": "vertical", "padding": 10, "spacing": 3, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "title": null, "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" }
Public Data Attributes:
locationThe location where the legend should draw itself.
orientationWhether the legend entries should be placed vertically or horizontally when they are drawn.
titleThe title text to render.
title_text_colorThe text color values for the title text.
title_text_outline_colorThe text outline color values for the title text.
title_text_alphaThe text alpha values for the title text.
title_text_fontThe text font values for the title text.
title_text_font_sizeThe text font size values for the title text.
title_text_font_styleThe text font style values for the title text.
title_text_alignThe text align values for the title text.
title_text_baselineThe text baseline values for the title text.
title_text_line_heightThe text line height values for the title text.
title_standoffThe distance (in pixels) to separate the title from the legend.
border_line_colorThe line color for the legend border outline.
border_line_alphaThe line alpha for the legend border outline.
border_line_widthThe line width for the legend border outline.
border_line_joinThe line join for the legend border outline.
border_line_capThe line cap for the legend border outline.
border_line_dashThe line dash for the legend border outline.
border_line_dash_offsetThe line dash offset for the legend border outline.
background_fill_colorThe fill color for the legend background style.
background_fill_alphaThe fill alpha for the legend background style.
inactive_fill_colorThe fill color for the legend item style when inactive.
inactive_fill_alphaThe fill alpha for the legend item style when inactive.
click_policyDefines what happens when a lengend's item is clicked.
label_text_colorThe text color for the legend labels.
label_text_outline_colorThe text outline color for the legend labels.
label_text_alphaThe text alpha for the legend labels.
label_text_fontThe text font for the legend labels.
label_text_font_sizeThe text font size for the legend labels.
label_text_font_styleThe text font style for the legend labels.
label_text_alignThe text align for the legend labels.
label_text_baselineThe text baseline for the legend labels.
label_text_line_heightThe text line height for the legend labels.
label_standoffThe distance (in pixels) to separate the label from its associated glyph.
label_heightThe minimum height (in pixels) of the area that legend labels should occupy.
label_widthThe minimum width (in pixels) of the area that legend labels should occupy.
glyph_heightThe height (in pixels) that the rendered legend glyph should occupy.
glyph_widthThe width (in pixels) that the rendered legend glyph should occupy.
marginAmount of margin around the legend.
paddingAmount of padding around the contents of the legend.
spacingAmount of spacing (in pixels) between legend entries.
itemsA list of
LegendIteminstances to be rendered in the legend.nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, background_fill_color, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- background_fill_color = '#ffffff'#
-
The fill color for the legend background style.
- border_line_dash = []#
- Type:
The line dash for the legend border outline.
- click_policy = 'none'#
- Type:
Defines what happens when a lengend’s item is clicked.
- inactive_fill_alpha = 0.7#
- Type:
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'#
-
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).
- items = []#
- Type:
A list of
LegendIteminstances 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:
The minimum height (in pixels) of the area that legend labels should occupy.
- label_standoff = 5#
- Type:
The distance (in pixels) to separate the label from its associated glyph.
- label_text_baseline = 'middle'#
- Type:
The text baseline for the legend labels.
- label_text_outline_color = None#
-
The text outline color for the legend labels.
- label_width = 20#
- Type:
The minimum width (in pixels) of the area that legend labels should occupy.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- location = 'top_right'#
-
The location where the legend should draw itself. It’s either one of
bokeh.core.enums.LegendLocation’s enumerated values, or a(x, y)tuple indicating an absolute location absolute location in screen coordinates (pixels from the bottom-left corner).
- name = None#
-
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 = 'vertical'#
- Type:
Whether the legend entries should be placed vertically or horizontally when they are drawn.
- padding = 10#
- Type:
Amount of padding around the contents of the legend. Only applicable when border is visible, otherwise collapses to 0.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_text_baseline = 'bottom'#
- Type:
The text baseline values for the title text.
- title_text_font_style = 'italic'#
-
The text font style values for the title text.
- title_text_outline_color = None#
-
The text outline color values for the title text.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class LegendItem(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
ModelJSON Prototype
{ "id": "p115529", "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 }
Public Data Attributes:
labelA label for this legend.
renderersA list of the glyph renderers to draw in the legend.
indexThe column data index to use for drawing the representative items.
visibleWhether the legend item should be displayed.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, label, name, renderers, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- index = None#
-
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
labelis a field, then it must be in the renderers’ data_source.
- name = None#
-
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:
A list of the glyph renderers to draw in the legend. If
labelis a field, then all data_sources of renderers must be the same.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class NormalHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
ArrowHeadRender a closed-body arrow head.
JSON Prototype
{ "fill_alpha": { "type": "value", "value": 1.0 }, "fill_color": { "type": "value", "value": "black" }, "id": "p115537", "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": [] }
Public Data Attributes:
line_colorThe line color values for the arrow head outline.
line_alphaThe line alpha values for the arrow head outline.
line_widthThe line width values for the arrow head outline.
line_joinThe line join values for the arrow head outline.
line_capThe line cap values for the arrow head outline.
line_dashThe line dash values for the arrow head outline.
line_dash_offsetThe line dash offset values for the arrow head outline.
fill_colorThe fill color values for the arrow head interior.
fill_alphaThe fill alpha values for the arrow head interior.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ArrowHeadsizeThe size, in pixels, of the arrow head.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
MarkingnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, fill_color, line_alpha, ...])Inherited from
ArrowHead__init__(*[, size, syncable, tags])Inherited from
Marking__init__(*[, syncable, tags])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the arrow head outline.
- name = None#
-
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:
The size, in pixels, of the arrow head.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class OpenHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
ArrowHeadRender an open-body arrow head.
JSON Prototype
{ "id": "p115551", "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": [] }
Public Data Attributes:
line_colorThe line color values for the arrow head outline.
line_alphaThe line alpha values for the arrow head outline.
line_widthThe line width values for the arrow head outline.
line_joinThe line join values for the arrow head outline.
line_capThe line cap values for the arrow head outline.
line_dashThe line dash values for the arrow head outline.
line_dash_offsetThe line dash offset values for the arrow head outline.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ArrowHeadsizeThe size, in pixels, of the arrow head.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
MarkingnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, line_cap, line_color, ...])Inherited from
ArrowHead__init__(*[, size, syncable, tags])Inherited from
Marking__init__(*[, syncable, tags])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the arrow head outline.
- name = None#
-
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:
The size, in pixels, of the arrow head.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class PolyAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
AnnotationRender a shaded polygonal region as an annotation.
See Polygon annotations for information on plotting polygon annotations.
JSON Prototype
{ "coordinates": null, "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, "id": "p115563", "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, "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" }
Public Data Attributes:
xsThe x-coordinates of the region to draw.
xs_unitsThe unit type for the
xsattribute.ysThe y-coordinates of the region to draw.
ys_unitsThe unit type for the
ysattribute.line_colorThe line color values for the polygon.
line_alphaThe line alpha values for the polygon.
line_widthThe line width values for the polygon.
line_joinThe line join values for the polygon.
line_capThe line cap values for the polygon.
line_dashThe line dash values for the polygon.
line_dash_offsetThe line dash offset values for the polygon.
fill_colorThe fill color values for the polygon.
fill_alphaThe fill alpha values for the polygon.
hatch_colorThe hatch color values for the polygon.
hatch_alphaThe hatch alpha values for the polygon.
hatch_scaleThe hatch scale values for the polygon.
hatch_patternThe hatch pattern values for the polygon.
hatch_weightThe hatch weight values for the polygon.
hatch_extraThe hatch extra values for the polygon.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, fill_alpha, fill_color, group, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- line_dash = []#
- Type:
The line dash values for the polygon.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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.
- x_range_name = 'default'#
- Type:
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_units = 'data'#
- Type:
The unit type for the
xsattribute. Interpreted as data units by default.
- y_range_name = 'default'#
- Type:
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_units = 'data'#
- Type:
The unit type for the
ysattribute. 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Slope(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
AnnotationRender a sloped line as an annotation.
See Slopes for information on plotting slopes.
JSON Prototype
{ "coordinates": null, "gradient": null, "group": null, "id": "p115590", "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, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_intercept": null, "y_range_name": "default" }
Public Data Attributes:
gradientThe gradient of the line, in data units
y_interceptThe y intercept of the line, in data units
line_colorThe line color values for the line.
line_alphaThe line alpha values for the line.
line_widthThe line width values for the line.
line_joinThe line join values for the line.
line_capThe line cap values for the line.
line_dashThe line dash values for the line.
line_dash_offsetThe line dash offset values for the line.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, gradient, group, level, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- gradient = None#
-
The gradient of the line, in data units
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- line_dash = []#
- Type:
The line dash values for the line.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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.
- x_range_name = 'default'#
- Type:
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#
-
The y intercept of the line, in data units
- y_range_name = 'default'#
- Type:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Span(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
AnnotationRender a horizontal or vertical line span.
See Spans for information on plotting spans.
JSON Prototype
{ "coordinates": null, "dimension": "width", "group": null, "id": "p115607", "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, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Public Data Attributes:
locationThe location of the span, along
dimension.location_unitsThe unit type for the location attribute.
dimensionThe direction of the span can be specified by setting this property to "height" (
ydirection) or "width" (xdirection).line_colorThe line color values for the span.
line_alphaThe line alpha values for the span.
line_widthThe line width values for the span.
line_joinThe line join values for the span.
line_capThe line cap values for the span.
line_dashThe line dash values for the span.
line_dash_offsetThe line dash offset values for the span.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, dimension, group, level, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- dimension = 'width'#
-
The direction of the span can be specified by setting this property to “height” (
ydirection) or “width” (xdirection).
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- line_dash = []#
- Type:
The line dash values for the span.
- location = None#
-
The location of the span, along
dimension.Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
- location_units = 'data'#
- Type:
The unit type for the location attribute. Interpreted as “data space” units by default.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class TeeHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
ArrowHeadRender a tee-style arrow head.
JSON Prototype
{ "id": "p115625", "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": [] }
Public Data Attributes:
line_colorThe line color values for the arrow head outline.
line_alphaThe line alpha values for the arrow head outline.
line_widthThe line width values for the arrow head outline.
line_joinThe line join values for the arrow head outline.
line_capThe line cap values for the arrow head outline.
line_dashThe line dash values for the arrow head outline.
line_dash_offsetThe line dash offset values for the arrow head outline.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ArrowHeadsizeThe size, in pixels, of the arrow head.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
MarkingnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, line_cap, line_color, ...])Inherited from
ArrowHead__init__(*[, size, syncable, tags])Inherited from
Marking__init__(*[, syncable, tags])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the arrow head outline.
- name = None#
-
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:
The size, in pixels, of the arrow head.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class TextAnnotation(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
AnnotationBase 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, "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, "coordinates": null, "group": null, "id": "p115637", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "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" }
Public Data Attributes:
textA text or LaTeX notation to render.
text_colorThe text color values for the text.
text_outline_colorThe text outline color values for the text.
text_alphaThe text alpha values for the text.
text_fontThe text font values for the text.
text_font_sizeThe text font size values for the text.
text_font_styleThe text font style values for the text.
text_alignThe text align values for the text.
text_baselineThe text baseline values for the text.
text_line_heightThe text line height values for the text.
background_fill_colorThe fill color values for the text bounding box.
background_fill_alphaThe fill alpha values for the text bounding box.
border_line_colorThe line color values for the text bounding box.
border_line_alphaThe line alpha values for the text bounding box.
border_line_widthThe line width values for the text bounding box.
border_line_joinThe line join values for the text bounding box.
border_line_capThe line cap values for the text bounding box.
border_line_dashThe line dash values for the text bounding box.
border_line_dash_offsetThe line dash offset values for the text bounding box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, background_fill_color, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- background_fill_color = None#
-
The fill color values for the text bounding box.
- border_line_dash = []#
- Type:
The line dash values for the text bounding box.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_baseline = 'bottom'#
- Type:
The text baseline values for the text.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Title(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
TextAnnotationRender 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, "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, "coordinates": null, "group": null, "id": "p115664", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "offset": 0, "standoff": 10, "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" }
Public Data Attributes:
vertical_alignAlignment of the text in its enclosing space, across the direction of the text.
alignAlignment of the text in its enclosing space, along the direction of the text.
offsetOffset the text by a number of pixels (can be positive or negative).
standoffnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
TextAnnotationtextA text or LaTeX notation to render.
text_colorThe text color values for the text.
text_outline_colorThe text outline color values for the text.
text_alphaThe text alpha values for the text.
text_fontThe text font values for the text.
text_font_sizeThe text font size values for the text.
text_font_styleThe text font style values for the text.
text_alignThe text align values for the text.
text_baselineThe text baseline values for the text.
text_line_heightThe text line height values for the text.
background_fill_colorThe fill color values for the text bounding box.
background_fill_alphaThe fill alpha values for the text bounding box.
border_line_colorThe line color values for the text bounding box.
border_line_alphaThe line alpha values for the text bounding box.
border_line_widthThe line width values for the text bounding box.
border_line_joinThe line join values for the text bounding box.
border_line_capThe line cap values for the text bounding box.
border_line_dashThe line dash values for the text bounding box.
border_line_dash_offsetThe line dash offset values for the text bounding box.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, background_fill_alpha, ...])Inherited from
TextAnnotation__init__(*[, background_fill_color, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- align = 'left'#
-
Alignment of the text in its enclosing space, along the direction of the text.
- background_fill_color = None#
-
The fill color values for the text bounding box.
- border_line_dash = []#
- Type:
The line dash values for the text bounding box.
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
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
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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_baseline = 'bottom'#
- Type:
The text baseline values for the text.
- vertical_align = 'bottom'#
- Type:
Alignment of the text in its enclosing space, across the direction of the text.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class ToolbarPanel(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
HTMLAnnotationJSON Prototype
{ "coordinates": null, "group": null, "id": "p115695", "js_event_callbacks": { "type": "map" }, "js_property_callbacks": { "type": "map" }, "level": "annotation", "name": null, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Public Data Attributes:
toolbarA toolbar to display.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
HTMLAnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, group, level, name, syncable, ...])Inherited from
HTMLAnnotation__init__(*[, group, level, name, syncable, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- level = 'annotation'#
- Type:
Specifies the level in which to paint this renderer.
- name = None#
-
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:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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.
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class VeeHead(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
ArrowHeadRender a vee-style arrow head.
JSON Prototype
{ "fill_alpha": { "type": "value", "value": 1.0 }, "fill_color": { "type": "value", "value": "black" }, "id": "p115704", "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": [] }
Public Data Attributes:
line_colorThe line color values for the arrow head outline.
line_alphaThe line alpha values for the arrow head outline.
line_widthThe line width values for the arrow head outline.
line_joinThe line join values for the arrow head outline.
line_capThe line cap values for the arrow head outline.
line_dashThe line dash values for the arrow head outline.
line_dash_offsetThe line dash offset values for the arrow head outline.
fill_colorThe fill color values for the arrow head interior.
fill_alphaThe fill alpha values for the arrow head interior.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ArrowHeadsizeThe size, in pixels, of the arrow head.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
MarkingnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, fill_color, line_alpha, ...])Inherited from
ArrowHead__init__(*[, size, syncable, tags])Inherited from
Marking__init__(*[, syncable, tags])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the arrow head outline.
- name = None#
-
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:
The size, in pixels, of the arrow head.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)
- class Whisker(*args: Any, id: ID | None = None, **kwargs: Any)[source]#
Bases:
DataAnnotationRender a whisker along a dimension.
See Whiskers for information on plotting whiskers.
JSON Prototype
{ "base": { "field": "base", "type": "field" }, "coordinates": null, "dimension": "height", "group": null, "id": "p115718", "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": "p115719", "name": "TeeHead", "type": "object" }, "name": null, "source": { "attributes": { "data": { "type": "map" }, "selected": { "attributes": { "indices": [], "line_indices": [] }, "id": "p115722", "name": "Selection", "type": "object" }, "selection_policy": { "id": "p115721", "name": "UnionRenderers", "type": "object" } }, "id": "p115720", "name": "ColumnDataSource", "type": "object" }, "subscribed_events": { "type": "set" }, "syncable": true, "tags": [], "upper": { "field": "upper", "type": "field" }, "upper_head": { "attributes": { "size": { "type": "value", "value": 10 } }, "id": "p115723", "name": "TeeHead", "type": "object" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
Public Data Attributes:
lower_unitsUnits to use for the associated property: canvas, screen or data
lowerThe coordinates of the lower end of the whiskers.
lower_headInstance of
ArrowHead.upper_unitsUnits to use for the associated property: canvas, screen or data
upperThe coordinates of the upper end of the whiskers.
upper_headInstance of
ArrowHead.base_unitsUnits to use for the associated property: canvas, screen or data
baseThe orthogonal coordinates of the upper and lower values.
dimensionThe direction of the whisker can be specified by setting this property to "height" (
ydirection) or "width" (xdirection).line_colorThe line color values for the whisker body.
line_alphaThe line alpha values for the whisker body.
line_widthThe line width values for the whisker body.
line_joinThe line join values for the whisker body.
line_capThe line cap values for the whisker body.
line_dashThe line dash values for the whisker body.
line_dash_offsetThe line dash offset values for the whisker body.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
DataAnnotationsourceLocal data source to use when rendering annotations on the plot.
nameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
AnnotationnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
RendererlevelSpecifies the level in which to paint this renderer.
visibleIs the renderer visible.
coordinatesx_range_nameA particular (named) x-range to use for computing screen locations when rendering glyphs on the plot.
y_range_nameA particular (named) y-range to use for computing screen locations when rendering glyphs on the plot.
groupnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)idsubscribed_eventsCollection of events that are subscribed to by Python callbacks.
Inherited from
ModelidrefnameAn arbitrary, user-supplied name for this model.
tagsAn optional list of arbitrary, user-supplied values to attach to this model.
js_event_callbacksA mapping of event names to lists of
CustomJScallbacks.js_property_callbacksA mapping of attribute names to lists of
CustomJScallbacks, to be set up on BokehJS side when the document is created.subscribed_eventsCollection of events that are subscribed to by Python callbacks.
syncableIndicates whether this model should be synchronized back to a Bokeh server when updated in a web browser.
documentThe
Documentthis model is attached to (can beNone)Inherited from
HasDocumentRefdocumentThe
Documentthis model is attached to (can beNone)Inherited from
PropertyCallbackManagerdocumentInherited from
EventCallbackManagerdocumentidsubscribed_eventsPublic Methods:
__init__(*[, base_units, coordinates, ...])Inherited from
DataAnnotation__init__(*[, group, level, name, source, ...])Inherited from
Annotation__init__(*[, group, level, name, syncable, ...])Inherited from
Renderer__init__(*[, group, level, name, syncable, ...])Inherited from
Model__init_subclass__()This method is called when a class is subclassed.
__new__(cls, *args[, id])__init__(*args, **kwargs)__str__()Return str(self).
__repr__()Return repr(self).
destroy()Clean up references to the document and property
parameters()Generate Python
Parametervalues suitable for functions that are derived from the glyph.js_on_event(event, *callbacks)js_link(attr, other, other_attr[, attr_selector])Link two Bokeh model properties using JavaScript.
js_on_change(event, *callbacks)Attach a
CustomJScallback to an arbitrary BokehJS model event.on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.references()Returns all
Modelsthat this object has references to.select(selector)Query this object and all of its references for objects that match the given selector.
select_one(selector)Query this object and all of its references for objects that match the given selector.
set_select(selector, updates)Update objects that match a given selector with the specified attribute/value updates.
to_serializable(serializer)Converts this object to a serializable representation.
trigger(attr, old, new[, hint, setter])Inherited from
HasProps__init_subclass__()This method is called when a class is subclassed.
__init__(**properties)__setattr__(name, value)Intercept attribute setting on HasProps in order to special case a few situations:
__getattr__(name)Intercept attribute setting on HasProps in order to special case a few situations:
__str__()Return str(self).
__repr__()Return repr(self).
equals(other)Structural equality of models.
to_serializable(serializer)Converts this object to a serializable representation.
set_from_json(name, value, *[, setter])Set a property value on this object from JSON.
update(**kwargs)Updates the object's properties from the given keyword arguments.
lookup()Find the
PropertyDescriptorfor a Bokeh property on a class, given the property name.Collect the names of properties on this class.
List of property descriptors in the order of definition.
Collect the names of all properties on this class that also have references.
Collect the names of all
DataSpecproperties on this class.properties_with_values(*[, ...])Collect a dict mapping property names to their values.
query_properties_with_values(query, *[, ...])Query the properties values of
HasPropsinstances with a predicate.Get any theme-provided overrides.
apply_theme(property_values)Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
Remove any themed values and restore defaults.
Inherited from
Serializableto_serializable(serializer)Converts this object to a serializable representation.
Inherited from
HasDocumentRef__init__(*args, **kw)Inherited from
PropertyCallbackManager__init__(*args, **kw)on_change(attr, *callbacks)Add a callback on this object to trigger when
attrchanges.remove_on_change(attr, *callbacks)Remove a callback from this object
trigger(attr, old, new[, hint, setter])Trigger callbacks for
attron this object.Inherited from
EventCallbackManager__init__(*args, **kw)on_event(event, *callbacks)Run callbacks when the specified event occurs on this Model
- base = Field(field='base', transform=Unspecified, units=Unspecified)#
- Type:
The orthogonal coordinates of the upper and lower values.
- base_units = 'data'#
- Type:
Units to use for the associated property: canvas, screen or data
- dimension = 'height'#
-
The direction of the whisker can be specified by setting this property to “height” (
ydirection) or “width” (xdirection).
- level = 'underlay'#
- Type:
Specifies the level in which to paint this renderer.
- line_cap = 'butt'#
- Type:
LineCapSpec
The line cap 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:
The line width values for the whisker body.
- lower = Field(field='lower', transform=Unspecified, units=Unspecified)#
- Type:
The coordinates of the lower end of the whiskers.
- lower_units = 'data'#
- Type:
Units to use for the associated property: canvas, screen or data
- name = None#
-
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.
- source = ColumnDataSource(id='p115828', ...)#
- Type:
Local data source to use when rendering annotations on the plot.
- syncable = True#
- Type:
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to
Falsemay be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.Note
Setting this property to
Falsewill prevent anyon_change()callbacks on this object from triggering. However, any JS-side callbacks will still work.
- tags = []#
- Type:
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
CustomJScallbacks, 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:
The coordinates of the upper end of the whiskers.
- upper_units = 'data'#
- Type:
Units to use for the associated property: canvas, screen or data
- x_range_name = 'default'#
- Type:
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:
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
HasPropsinstance should modify it).- Parameters:
property_values (dict) – theme values to use in place of defaults
- Returns:
None
- classmethod dataspecs() dict[str, DataSpec]#
Collect the names of all
DataSpecproperties on this class.This method always traverses the class hierarchy and includes properties defined on any parent classes.
- classmethod descriptors() list[PropertyDescriptor[Any]]#
List of property descriptors in the order of definition.
- 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
- js_link(attr: str, other: Model, other_attr: str, attr_selector: int | str | None = None) None#
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a
CustomJScallback to update one Bokeh model property whenever another changes value.- Parameters:
Added in version 1.1
- Raises:
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: JSEventCallback) None#
Attach a
CustomJScallback 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
PropertyDescriptorfor a Bokeh property on a class, given the property name.- Parameters:
- Returns:
descriptor for property named
name- Return type:
- on_change(attr: str, *callbacks: PropertyCallback) None#
Add a callback on this object to trigger when
attrchanges.- Parameters:
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
- Returns:
None
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
- on_event(event: str | type[Event], *callbacks: EventCallback) 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
Parametervalues 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.
- 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.
- 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
HasPropsinstances 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:
- 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
Noneif 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#
- 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)