Renderers for various kinds of annotations that can be added to Bokeh plots
Annotation
Bases: bokeh.models.renderers.Renderer
bokeh.models.renderers.Renderer
Base class for all annotation models.
Note
This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.
js_event_callbacks
Dict(String, List(Instance(CustomJS)))
Dict
String
List
Instance
CustomJS
{}
A mapping of event names to lists of CustomJS callbacks.
Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:
Model.js_on_event
callback = CustomJS(code="console.log('tap event occurred')") plot.js_on_event('tap', callback)
js_property_callbacks
A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.
Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:
Model.js_on_change
callback = CustomJS(code="console.log('stuff')") plot.x_range.js_on_change('start', callback)
level
Enum(RenderLevel)
Enum
RenderLevel
'annotation'
Specifies the level in which to paint this renderer.
name
Nullable(String)
Nullable
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', ...)]
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.
subscribed_events
List(String)
[]
List of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.
syncable
Bool
True
Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.
False
Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.
on_change()
tags
List(AnyRef)
AnyRef
An optional list of arbitrary, user-supplied values to attach to this model.
This data can be useful when querying the document to retrieve specific Bokeh models:
>>> r = plot.circle([1,2,3], [4,5,6]) >>> r.tags = ["foo", 10] >>> plot.select(tags=['foo', 10]) [GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]
Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.
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
Is the renderer visible.
x_range_name
'default'
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
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
Apply a set of theme values which will be used rather than defaults, but will not override application-set values.
The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).
HasProps
property_values (dict) – theme values to use in place of defaults
dataspecs
Collect the names of all DataSpec properties on this class.
DataSpec
This method always traverses the class hierarchy and includes properties defined on any parent classes.
names of DataSpec properties
set[str]
dataspecs_with_props
Collect a dict mapping the names of all DataSpec properties on this class to the associated properties.
mapping of names and DataSpec properties
dict[str, DataSpec]
equals
Structural equality of models.
other (HasProps) – the other instance to compare to
True, if properties are structurally equal, otherwise False
js_link
Link two Bokeh model properties using JavaScript.
This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.
attr (str) – The name of a Bokeh property on this model
other (Model) – A Bokeh model to link to self.attr
other_attr (str) – The property on other to link together
other
attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr
attr
Added in version 1.1
ValueError –
Examples
This code with js_link:
select.js_link('value', plot, 'sizing_mode')
is equivalent to the following:
from bokeh.models import CustomJS select.js_on_change('value', CustomJS(args=dict(other=plot), code="other.sizing_mode = this.value" ) )
Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:
range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)
which is equivalent to:
from bokeh.models import CustomJS range_slider.js_on_change('value', CustomJS(args=dict(other=plot.x_range), code="other.start = this.value[0]" ) )
js_on_change
Attach a CustomJS callback to an arbitrary BokehJS model event.
On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:
"change:property_name"
"change:"
# 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:
ColumnDataSource
"stream"
source.js_on_change('streaming', callback)
layout
lookup
Find the PropertyDescriptor for a Bokeh property on a class, given the property name.
PropertyDescriptor
name (str) – name of the property to search for
raises (bool) – whether to raise or return None if missing
descriptor for property named name
on_change
Add a callback on this object to trigger when attr changes.
attr (str) – an attribute name on this object
*callbacks (callable) – callback functions to register
Example:
widget.on_change('value', callback1, callback2, ..., callback_n)
on_event
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.
properties
Collect the names of properties on this class.
This method optionally traverses the class hierarchy and includes properties defined on any parent classes.
with_bases (bool, optional) – Whether to include properties defined on parent classes in the results. (default: True)
property names
properties_containers
Collect the names of all container properties on this class.
names of container properties
properties_with_refs
Collect the names of all properties on this class that also have references.
names of properties that have references
properties_with_values
Collect a dict mapping property names to their values.
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.
include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)
mapping from property names to their values
dict
query_properties_with_values
Query the properties values of HasProps instances with a predicate.
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)
mapping of property names and values for matching properties
references
Returns all Models that this object has references to.
Models
remove_on_change
Remove a callback from this object
select
Query this object and all of its references for objects that match the given selector.
selector (JSON-like) –
seq[Model]
select_one
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
Model
set_from_json
Set a property value on this object from JSON.
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.
set_select
Update objects that match a given selector with the specified attribute/value updates.
updates (dict) –
themed_values
Get any theme-provided overrides.
Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.
dict or None
to_json
Returns a dictionary of the attributes of this object, containing only “JSON types” (string, number, boolean, none, dict, list).
References to other objects are serialized as “refs” (just the object ID and type info), so the deserializer will need to separately have the full attributes of those other objects.
There’s no corresponding from_json() because to deserialize an object is normally done in the context of a Document (since the Document can resolve references).
from_json()
For most purposes it’s best to serialize and deserialize entire documents.
include_defaults (bool) – whether to include attributes that haven’t been changed from the default
to_json_string
Returns a JSON string encoding the attributes of this object.
References to other objects are serialized as references (just the object ID and type info), so the deserializer will need to separately have the full attributes of those other objects.
There’s no corresponding from_json_string() because to deserialize an object is normally done in the context of a Document (since the Document can resolve references).
from_json_string()
trigger
unapply_theme
Remove any themed values and restore defaults.
update
Updates the object’s properties from the given keyword arguments.
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)
update_from_json
Updates the object’s properties from a JSON attributes dictionary.
json_attributes – (JSON-dict) : attributes and values to update
document
The Document this model is attached to (can be None)
Document
struct
A Bokeh protocol “structure” of this model, i.e. a dict of the form:
{ 'type' : << view model name >> 'id' : << unique model id >> }
Additionally there may be a subtype field if this model is a subtype.
{ "id": "13087", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "name": null, "subscribed_events": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Arrow
Bases: bokeh.models.annotations.DataAnnotation
bokeh.models.annotations.DataAnnotation
Render arrows as an annotation.
See Arrows for information on plotting arrows.
end
Nullable(Instance(ArrowHead))
ArrowHead
OpenHead(id='13102', ...)
Instance of ArrowHead.
end_units
Enum(SpatialUnits)
SpatialUnits
'data'
The unit type for the end_x and end_y attributes. Interpreted as “data space” units by default.
line_alpha
AlphaSpec
1.0
The line alpha values for the arrow body.
line_cap
LineCapSpec
'butt'
The line cap values for the arrow body.
line_color
ColorSpec
'black'
The line color values for the arrow body.
line_dash
DashPatternSpec
The line dash values for the arrow body.
line_dash_offset
IntSpec
0
The line dash offset values for the arrow body.
line_join
LineJoinSpec
'bevel'
The line join values for the arrow body.
line_width
NumberSpec
1
The line width values for the arrow body.
source
Instance(DataSource)
DataSource
ColumnDataSource(id='13116', ...)
Local data source to use when rendering annotations on the plot.
start
start_units
The unit type for the start_x and start_y attributes. Interpreted as “data space” units by default.
x_end
{'field': 'x_end'}
The x-coordinates to locate the end of the arrows.
x_start
{'field': 'x_start'}
The x-coordinates to locate the start of the arrows.
y_end
{'field': 'y_end'}
The y-coordinates to locate the end of the arrows.
y_start
{'field': 'y_start'}
The y-coordinates to locate the start of the arrows.
{ "end": { "id": "13100" }, "end_units": "data", "id": "13098", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "line_alpha": { "value": 1.0 }, "line_cap": { "value": "butt" }, "line_color": { "value": "black" }, "line_dash": { "value": [] }, "line_dash_offset": { "value": 0 }, "line_join": { "value": "bevel" }, "line_width": { "value": 1 }, "name": null, "source": { "id": "13099" }, "start": null, "start_units": "data", "subscribed_events": [], "syncable": true, "tags": [], "visible": true, "x_end": { "field": "x_end" }, "x_range_name": "default", "x_start": { "field": "x_start" }, "y_end": { "field": "y_end" }, "y_range_name": "default", "y_start": { "field": "y_start" } }
Band
Render a filled area band along a dimension.
See Bands for information on plotting bands.
base
PropertyUnitsSpec
{'field': 'base'}
The orthogonal coordinates of the upper and lower values.
dimension
Enum(Dimension)
Dimension
'height'
The direction of the band can be specified by setting this property to “height” (y direction) or “width” (x direction).
y
x
fill_alpha
Alpha
0.4
The fill alpha values for the band.
fill_color
Nullable(Color)
Color
'#fff9ba'
The fill color values for the band.
0.3
The line alpha values for the band.
Enum(LineCap)
LineCap
The line cap values for the band.
'#cccccc'
The line color values for the band.
DashPattern
The line dash values for the band.
Int
The line dash offset values for the band.
Enum(LineJoin)
LineJoin
The line join values for the band.
Float
The line width values for the band.
lower
{'field': 'lower'}
The coordinates of the lower portion of the filled area band.
ColumnDataSource(id='13148', ...)
upper
{'field': 'upper'}
The coordinates of the upper portion of the filled area band.
{ "base": { "field": "base" }, "dimension": "height", "fill_alpha": 0.4, "fill_color": "#fff9ba", "id": "13129", "js_event_callbacks": {}, "js_property_callbacks": {}, "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" }, "name": null, "source": { "id": "13130" }, "subscribed_events": [], "syncable": true, "tags": [], "upper": { "field": "upper" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }
BoxAnnotation
Bases: bokeh.models.annotations.Annotation
bokeh.models.annotations.Annotation
Render a shaded rectangular region as an annotation.
See Box annotations for information on plotting box annotations.
bottom
Either(Null, Auto, NumberSpec)
Either
Null
Auto
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
The unit type for the bottom attribute. Interpreted as “data space” units by default.
The fill alpha values for the box.
The fill color values for the box.
hatch_alpha
The hatch alpha values for the box.
hatch_color
The hatch color values for the box.
hatch_extra
Dict(String, Instance(Texture))
Texture
The hatch extra values for the box.
hatch_pattern
The hatch pattern values for the box.
hatch_scale
Size
12.0
The hatch scale values for the box.
hatch_weight
The hatch weight values for the box.
left
The x-coordinates of the left edge of the box annotation.
left_units
The unit type for the left attribute. Interpreted as “data space” units by default.
The line alpha values for the box.
The line cap values for the box.
The line color values for the box.
The line dash values for the box.
The line dash offset values for the box.
The line join values for the box.
The line width values for the box.
render_mode
Enum(RenderMode)
RenderMode
'canvas'
Specifies whether the box is rendered as a canvas element or as an css element overlaid on the canvas. The default mode is “canvas”.
Warning
The line_dash and line_dash_offset attributes aren’t supported if the render_mode is set to “css”
right
The x-coordinates of the right edge of the box annotation.
right_units
The unit type for the right attribute. Interpreted as “data space” units by default.
top
The y-coordinates of the top edge of the box annotation.
top_units
The unit type for the top attribute. Interpreted as “data space” units by default.
{ "bottom": null, "bottom_units": "data", "fill_alpha": 0.4, "fill_color": "#fff9ba", "hatch_alpha": 1.0, "hatch_color": "black", "hatch_extra": {}, "hatch_pattern": null, "hatch_scale": 12.0, "hatch_weight": 1.0, "id": "13156", "js_event_callbacks": {}, "js_property_callbacks": {}, "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, "render_mode": "canvas", "right": null, "right_units": "data", "subscribed_events": [], "syncable": true, "tags": [], "top": null, "top_units": "data", "visible": true, "x_range_name": "default", "y_range_name": "default" }
ColorBar
Render a color bar based on a color mapper.
See Color bars for information on plotting color bars.
background_fill_alpha
0.95
The fill alpha for the color bar background style.
background_fill_color
'#ffffff'
The fill color for the color bar background style.
bar_line_alpha
The line alpha for the color scale bar outline.
bar_line_cap
The line cap for the color scale bar outline.
bar_line_color
The line color for the color scale bar outline.
bar_line_dash
The line dash for the color scale bar outline.
bar_line_dash_offset
The line dash offset for the color scale bar outline.
bar_line_join
The line join for the color scale bar outline.
bar_line_width
The line width for the color scale bar outline.
border_line_alpha
The line alpha for the color bar border outline.
border_line_cap
The line cap for the color bar border outline.
border_line_color
The line color for the color bar border outline.
border_line_dash
The line dash for the color bar border outline.
border_line_dash_offset
The line dash offset for the color bar border outline.
border_line_join
The line join for the color bar border outline.
border_line_width
The line width for the color bar border outline.
color_mapper
Instance(ColorMapper)
ColorMapper
Undefined
A color mapper containing a color palette to render.
If the low and high attributes of the ColorMapper aren’t set, ticks and tick labels won’t be rendered. Additionally, if a LogTicker is passed to the ticker argument and either or both of the logarithms of low and high values of the color_mapper are non-numeric (i.e. low=0), the tick and tick labels won’t be rendered.
LogTicker
formatter
Either(Instance(TickFormatter), Auto)
TickFormatter
'auto'
A TickFormatter to use for formatting the visual appearance of ticks.
height
Either(Auto, Int)
The height (in pixels) that the color scale should occupy.
label_standoff
5
The distance (in pixels) to separate the tick labels from the color bar.
location
Either(Enum(Anchor), Tuple(Float, Float))
Anchor
Tuple
'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).
bokeh.core.enums.Anchor
(x, y)
If the color bar is placed in a side panel, the location will likely have to be set to (0,0).
major_label_overrides
Dict(Either(Float, String), String)
Provide explicit tick label values for specific tick locations that override normal formatting.
major_label_policy
Instance(LabelingPolicy)
LabelingPolicy
NoOverlap(id='13219', ...)
Allows to filter out labels, e.g. declutter labels to avoid overlap.
major_label_text_align
Enum(TextAlign)
TextAlign
'left'
The text align of the major tick labels.
major_label_text_alpha
The text alpha of the major tick labels.
major_label_text_baseline
Enum(TextBaseline)
TextBaseline
'bottom'
The text baseline of the major tick labels.
major_label_text_color
'#444444'
The text color of the major tick labels.
major_label_text_font
'helvetica'
The text font of the major tick labels.
major_label_text_font_size
FontSize
'11px'
The text font size of the major tick labels.
major_label_text_font_style
Enum(FontStyle)
FontStyle
'normal'
The text font style of the major tick labels.
major_label_text_line_height
1.2
The text line height of the major tick labels.
major_tick_in
The distance (in pixels) that major ticks should extend into the main plot area.
major_tick_line_alpha
The line alpha of the major ticks.
major_tick_line_cap
The line cap of the major ticks.
major_tick_line_color
The line color of the major ticks.
major_tick_line_dash
The line dash of the major ticks.
major_tick_line_dash_offset
The line dash offset of the major ticks.
major_tick_line_join
The line join of the major ticks.
major_tick_line_width
The line width of the major ticks.
major_tick_out
The distance (in pixels) that major ticks should extend out of the main plot area.
margin
30
Amount of margin (in pixels) around the outside of the color bar.
minor_tick_in
The distance (in pixels) that minor ticks should extend into the main plot area.
minor_tick_line_alpha
The line alpha of the minor ticks.
minor_tick_line_cap
The line cap of the minor ticks.
minor_tick_line_color
The line color of the minor ticks.
minor_tick_line_dash
The line dash of the minor ticks.
minor_tick_line_dash_offset
The line dash offset of the minor ticks.
minor_tick_line_join
The line join of the minor ticks.
minor_tick_line_width
The line width of the minor ticks.
minor_tick_out
orientation
Either(Enum(Orientation), Auto)
Orientation
Whether the color bar should be oriented vertically or horizontally.
padding
10
Amount of padding (in pixels) between the color scale and color bar border.
scale_alpha
The alpha with which to render the color scale.
ticker
Either(Instance(Ticker), Auto)
Ticker
A Ticker to use for computing locations of axis components.
title
The title text to render.
title_standoff
2
The distance (in pixels) to separate the title from the color bar.
title_text_align
The text align values for the title text.
title_text_alpha
The text alpha values for the title text.
title_text_baseline
The text baseline values for the title text.
title_text_color
The text color values for the title text.
title_text_font
The text font values for the title text.
title_text_font_size
'13px'
The text font size values for the title text.
title_text_font_style
'italic'
The text font style values for the title text.
title_text_line_height
The text line height values for the title text.
width
The width (in pixels) that the color scale should occupy.
{ "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, "formatter": "auto", "height": "auto", "id": "13191", "js_event_callbacks": {}, "js_property_callbacks": {}, "label_standoff": 5, "level": "annotation", "location": "top_right", "major_label_overrides": {}, "major_label_policy": { "id": "13192" }, "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_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": [], "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, "visible": true, "width": "auto", "x_range_name": "default", "y_range_name": "default" }
DataAnnotation
Base class for annotations that utilize a data source.
ColumnDataSource(id='13276', ...)
{ "id": "13269", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "name": null, "source": { "id": "13270" }, "subscribed_events": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Label
Bases: bokeh.models.annotations.TextAnnotation
bokeh.models.annotations.TextAnnotation
Render a single text label as an annotation.
Label will render a single text label at given x and y coordinates, which can be in either screen (pixel) space, or data (axis range) space.
The label can also be configured with a screen space offset from x and y, by using the x_offset and y_offset properties.
x_offset
y_offset
Additionally, the label can be rotated with the angle property.
angle
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.
Angle
The angle to rotate the text, as measured from the horizontal.
The center of rotation for canvas and css render_modes is different. For render_mode=”canvas” the label is rotated from the top-left corner of the annotation, while for render_mode=”css” the annotation is rotated around it’s center.
angle_units
Enum(AngleUnits)
AngleUnits
'rad'
Acceptable values for units are "rad" and "deg"
"rad"
"deg"
The fill alpha values for the text bounding box.
The fill color values for the text bounding box.
The line alpha values for the text bounding box.
The line cap values for the text bounding box.
The line color values for the text bounding box.
The line dash values for the text bounding box.
The line dash offset values for the text bounding box.
The line join values for the text bounding box.
The line width values for the text bounding box.
Specifies whether the text is rendered as a canvas element or as a CSS element overlaid on the canvas. The default mode is “canvas”.
The CSS labels won’t be present in the output using the “save” tool.
Not all visual styling properties are supported if the render_mode is set to “css”. The border_line_dash property isn’t fully supported and border_line_dash_offset isn’t supported at all. Setting text_alpha will modify the opacity of the entire background box and border in addition to the text. Finally, clipping Label annotations inside of the plot area isn’t supported in “css” mode.
text
''
The text value to render.
text_align
The text align values for the text.
text_alpha
The text alpha values for the text.
text_baseline
The text baseline values for the text.
text_color
The text color values for the text.
text_font
The text font values for the text.
text_font_size
'16px'
The text font size values for the text.
text_font_style
The text font style values for the text.
text_line_height
The text line height values for the text.
NonNullable(Float)
NonNullable
The x-coordinate in screen coordinates to locate the text anchors.
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_units
The unit type for the x attribute. Interpreted as “data space” units by default.
The y-coordinate in screen coordinates to locate the text anchors.
Offset value to apply to the y-coordinate.
y_units
The unit type for the y attribute. Interpreted as “data space” units by default.
{ "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, "id": "13283", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "name": null, "render_mode": "canvas", "subscribed_events": [], "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, "visible": true, "x_offset": 0, "x_range_name": "default", "x_units": "data", "y_offset": 0, "y_range_name": "default", "y_units": "data" }
LabelSet
Render multiple text labels as annotations.
LabelSet will render multiple text labels at given x and y coordinates, which can be in either screen (pixel) space, or data (axis range) space. In this case (as opposed to the single Label model), x and y can also be the name of a column from a ColumnDataSource, in which case the labels will be “vectorized” using coordinate values from the specified columns.
The label can also be configured with a screen space offset from x and y, by using the x_offset and y_offset properties. These offsets may be vectorized by giving the name of a data source column.
Additionally, the label can be rotated with the angle property (which may also be a column name.)
The data source is provided by setting the source property.
AngleSpec
The angles to rotate the text, as measured from the horizontal.
ColumnDataSource(id='13339', ...)
StringSpec
{'field': 'text'}
The text values to render.
TextAlignSpec
TextBaselineSpec
{'value': 'helvetica'}
FontSizeSpec
{'value': '16px'}
FontStyleSpec
{'field': 'x'}
The x-coordinates to locate the text anchors.
Offset values to apply to the x-coordinates.
The unit type for the xs attribute. Interpreted as “data space” units by default.
xs
{'field': 'y'}
The y-coordinates to locate the text anchors.
Offset values to apply to the y-coordinates.
The unit type for the ys attribute. Interpreted as “data space” units by default.
ys
{ "angle": { "value": 0 }, "background_fill_alpha": { "value": 1.0 }, "background_fill_color": { "value": null }, "border_line_alpha": { "value": 1.0 }, "border_line_cap": { "value": "butt" }, "border_line_color": { "value": null }, "border_line_dash": { "value": [] }, "border_line_dash_offset": { "value": 0 }, "border_line_join": { "value": "bevel" }, "border_line_width": { "value": 1 }, "id": "13321", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "name": null, "render_mode": "canvas", "source": { "id": "13322" }, "subscribed_events": [], "syncable": true, "tags": [], "text": { "field": "text" }, "text_align": { "value": "left" }, "text_alpha": { "value": 1.0 }, "text_baseline": { "value": "bottom" }, "text_color": { "value": "#444444" }, "text_font": { "value": "helvetica" }, "text_font_size": { "value": "16px" }, "text_font_style": { "value": "normal" }, "text_line_height": { "value": 1.2 }, "visible": true, "x": { "field": "x" }, "x_offset": { "value": 0 }, "x_range_name": "default", "x_units": "data", "y": { "field": "y" }, "y_offset": { "value": 0 }, "y_range_name": "default", "y_units": "data" }
Legend
Render informational legends for a plot.
See Legends for information on plotting legends.
The fill alpha for the legend background style.
The fill color for the legend background style.
0.5
The line alpha for the legend border outline.
The line cap for the legend border outline.
'#e5e5e5'
The line color for the legend border outline.
The line dash for the legend border outline.
The line dash offset for the legend border outline.
The line join for the legend border outline.
The line width for the legend border outline.
click_policy
Enum(LegendClickPolicy)
LegendClickPolicy
'none'
Defines what happens when a lengend’s item is clicked.
glyph_height
20
The height (in pixels) that the rendered legend glyph should occupy.
glyph_width
The width (in pixels) that the rendered legend glyph should occupy.
inactive_fill_alpha
0.7
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
List(Instance(LegendItem))
LegendItem
A list of LegendItem instances to be rendered in the legend.
This can be specified explicitly, for instance:
legend = Legend(items=[ LegendItem(label="sin(x)" , renderers=[r0, r1]), LegendItem(label="2*sin(x)" , renderers=[r2]), LegendItem(label="3*sin(x)" , renderers=[r3, r4]) ])
But as a convenience, can also be given more compactly as a list of tuples:
legend = Legend(items=[ ("sin(x)" , [r0, r1]), ("2*sin(x)" , [r2]), ("3*sin(x)" , [r3, r4]) ])
where each tuple is of the form: (label, renderers).
label_height
The minimum height (in pixels) of the area that legend labels should occupy.
The distance (in pixels) to separate the label from its associated glyph.
label_text_align
The text align for the legend labels.
label_text_alpha
The text alpha for the legend labels.
label_text_baseline
'middle'
The text baseline for the legend labels.
label_text_color
The text color for the legend labels.
label_text_font
The text font for the legend labels.
label_text_font_size
The text font size for the legend labels.
label_text_font_style
The text font style for the legend labels.
label_text_line_height
The text line height for the legend labels.
label_width
The minimum width (in pixels) of the area that legend labels should occupy.
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).
bokeh.core.enums.LegendLocation
Amount of margin around the legend.
Enum(Orientation)
'vertical'
Whether the legend entries should be placed vertically or horizontally when they are drawn.
Amount of padding around the contents of the legend. Only applicable when border is visible, otherwise collapses to 0.
spacing
3
Amount of spacing (in pixels) between legend entries.
The distance (in pixels) to separate the title from the legend.
{ "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", "glyph_height": 20, "glyph_width": 20, "id": "13361", "inactive_fill_alpha": 0.7, "inactive_fill_color": "white", "items": [], "js_event_callbacks": {}, "js_property_callbacks": {}, "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_width": 20, "level": "annotation", "location": "top_right", "margin": 10, "name": null, "orientation": "vertical", "padding": 10, "spacing": 3, "subscribed_events": [], "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, "visible": true, "x_range_name": "default", "y_range_name": "default" }
Bases: bokeh.model.Model
bokeh.model.Model
index
Nullable(Int)
The column data index to use for drawing the representative items.
If None (the default), then Bokeh will automatically choose an index to use. If the label does not refer to a data column name, this is typically the first data point in the data source. Otherwise, if the label does refer to a column name, the legend will have “groupby” behavior, and will choose and display representative points from every “group” in the column.
If set to a number, Bokeh will use that number as the index in all cases.
label
NullStringSpec
A label for this legend. Can be a string, or a column of a ColumnDataSource. If label is a field, then it must be in the renderers’ data_source.
renderers
List(Instance(GlyphRenderer))
GlyphRenderer
A list of the glyph renderers to draw in the legend. If label is a field, then all data_sources of renderers must be the same.
{ "id": "13413", "index": null, "js_event_callbacks": {}, "js_property_callbacks": {}, "label": { "value": null }, "name": null, "renderers": [], "subscribed_events": [], "syncable": true, "tags": [] }
PolyAnnotation
Render a shaded polygonal region as an annotation.
See Polygon annotations for information on plotting polygon annotations.
The fill alpha values for the polygon.
The fill color values for the polygon.
The hatch alpha values for the polygon.
The hatch color values for the polygon.
The hatch extra values for the polygon.
The hatch pattern values for the polygon.
The hatch scale values for the polygon.
The hatch weight values for the polygon.
The line alpha values for the polygon.
The line cap values for the polygon.
The line color values for the polygon.
The line dash values for the polygon.
The line dash offset values for the polygon.
The line join values for the polygon.
The line width values for the polygon.
Seq(Float)
Seq
The x-coordinates of the region to draw.
xs_units
The y-coordinates of the region to draw.
ys_units
{ "fill_alpha": 0.4, "fill_color": "#fff9ba", "hatch_alpha": 1.0, "hatch_color": "black", "hatch_extra": {}, "hatch_pattern": null, "hatch_scale": 12.0, "hatch_weight": 1.0, "id": "13423", "js_event_callbacks": {}, "js_property_callbacks": {}, "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": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "xs": [], "xs_units": "data", "y_range_name": "default", "ys": [], "ys_units": "data" }
Slope
Render a sloped line as an annotation.
See Slopes for information on plotting slopes.
gradient
Nullable(Float)
The gradient of the line, in data units
The line alpha values for the line.
The line cap values for the line.
The line color values for the line.
The line dash values for the line.
The line dash offset values for the line.
The line join values for the line.
The line width values for the line.
y_intercept
The y intercept of the line, in data units
{ "gradient": null, "id": "13453", "js_event_callbacks": {}, "js_property_callbacks": {}, "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": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_intercept": null, "y_range_name": "default" }
Span
Render a horizontal or vertical line span.
See Spans for information on plotting spans.
'width'
The direction of the span can be specified by setting this property to “height” (y direction) or “width” (x direction).
The line alpha values for the span.
The line cap values for the span.
The line color values for the span.
The line dash values for the span.
The line dash offset values for the span.
The line join values for the span.
The line width values for the span.
The location of the span, along dimension.
location_units
The unit type for the location attribute. Interpreted as “data space” units by default.
Specifies whether the span is rendered as a canvas element or as a CSS element overlaid on the canvas. The default mode is “canvas”.
{ "dimension": "width", "id": "13473", "js_event_callbacks": {}, "js_property_callbacks": {}, "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, "render_mode": "canvas", "subscribed_events": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
TextAnnotation
Base class for text annotation models such as labels and titles.
{ "id": "13495", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "name": null, "render_mode": "canvas", "subscribed_events": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Title
Render a single title box as an annotation.
See Titles for information on plotting titles.
align
Alignment of the text in its enclosing space, along the direction of the text.
offset
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
above: shifts title right
right: shifts title down
below: shifts title right
left: shifts title up
standoff
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).
A color to use to fill text with.
Acceptable values are:
any of the named CSS colors, e.g 'green', 'indigo'
'green'
'indigo'
RGB(A) hex strings, e.g., '#FF0000', '#44444444'
'#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)'
'rgba(255, 0, 127, 0.6)'
'rgb(0 127 0 / 1.0)'
'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
Name of a font to use for rendering text, e.g., 'times', 'helvetica'.
'times'
'bold'
A style to use for rendering text.
'normal' normal text
'italic' italic text
'bold' bold text
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
Enum(VerticalAlign)
VerticalAlign
Alignment of the text in its enclosing space, across the direction of the text.
{ "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, "id": "13507", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "name": null, "offset": 0, "render_mode": "canvas", "standoff": 10, "subscribed_events": [], "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, "vertical_align": "bottom", "visible": true, "x_range_name": "default", "y_range_name": "default" }
ToolbarPanel
toolbar
Instance(Toolbar)
Toolbar
A toolbar to display.
{ "id": "13538", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "annotation", "name": null, "subscribed_events": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Tooltip
Render a tooltip.
This model is currently managed by BokehJS and is not useful directly from python.
attachment
Enum(TooltipAttachment)
TooltipAttachment
'horizontal'
Whether the tooltip should be displayed to the left or right of the cursor position or above or below it, or if it should be automatically placed in the horizontal or vertical dimension.
inner_only
Whether to display outside a central plot frame area.
'overlay'
show_arrow
Whether tooltip’s arrow should be shown.
{ "attachment": "horizontal", "id": "13550", "inner_only": true, "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "overlay", "name": null, "show_arrow": true, "subscribed_events": [], "syncable": true, "tags": [], "visible": true, "x_range_name": "default", "y_range_name": "default" }
Whisker
Render a whisker along a dimension.
See Whiskers for information on plotting whiskers.
The direction of the whisker can be specified by setting this property to “height” (y direction) or “width” (x direction).
'underlay'
The line alpha values for the whisker body.
The line cap values for the whisker body.
The line color values for the whisker body.
The line dash values for the whisker body.
The line dash offset values for the whisker body.
The line join values for the whisker body.
The line width values for the whisker body.
The coordinates of the lower end of the whiskers.
lower_head
TeeHead(id='13582', ...)
ColumnDataSource(id='13585', ...)
The coordinates of the upper end of the whiskers.
upper_head
TeeHead(id='13591', ...)
{ "base": { "field": "base" }, "dimension": "height", "id": "13564", "js_event_callbacks": {}, "js_property_callbacks": {}, "level": "underlay", "line_alpha": { "value": 1.0 }, "line_cap": { "value": "butt" }, "line_color": { "value": "black" }, "line_dash": { "value": [] }, "line_dash_offset": { "value": 0 }, "line_join": { "value": "bevel" }, "line_width": { "value": 1 }, "lower": { "field": "lower" }, "lower_head": { "id": "13567" }, "name": null, "source": { "id": "13566" }, "subscribed_events": [], "syncable": true, "tags": [], "upper": { "field": "upper" }, "upper_head": { "id": "13565" }, "visible": true, "x_range_name": "default", "y_range_name": "default" }