bokeh.models.annotations¶
Renderers for various kinds of annotations that can be added to Bokeh plots
-
class
Annotation(**kwargs)[source]¶ Bases:
bokeh.models.renderers.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.
-
class
Arrow(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender an arrow as an annotation.
-
end_units¶ property type:
Enum(SpatialUnits)The unit type for the end_x and end_y attributes. Interpreted as “data space” units by default.
-
line_alpha¶ property type:
NumberSpecThe line alpha values for the arrow body.
-
line_dash¶ property type:
DashPatternThe line dash values for the arrow body.
-
line_width¶ property type:
NumberSpecThe line width values for the arrow body.
-
source¶ property type:
Instance(DataSource)Local data source to use when rendering annotations on the plot.
-
start_units¶ property type:
Enum(SpatialUnits)The unit type for the start_x and start_y attributes. Interpreted as “data space” units by default.
-
x_end¶ property type:
NumberSpecThe x-coordinates to locate the end of the arrows.
-
x_range_name¶ property type:
StringA particular (named) x-range to use for computing screen locations when rendering annotations on the plot. If unset, use the default x-range.
-
x_start¶ property type:
NumberSpecThe x-coordinates to locate the start of the arrows.
-
y_end¶ property type:
NumberSpecThe y-coordinates to locate the end of the arrows.
-
y_range_name¶ property type:
StringA particular (named) y-range to use for computing screen locations when rendering annotations on the plot. If unset, use the default y-range.
-
y_start¶ property type:
NumberSpecThe y-coordinates to locate the start of the arrows.
-
-
class
Band(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a filled area band along a dimension.
-
base¶ property type:
DistanceSpecThe orthogonal coordinates of the upper and lower values.
-
base_units¶ property type:
Enum(SpatialUnits)
-
dimension¶ property type:
Enum(Dimension)The direction of the band can be specified by setting this property to “height” (
ydirection) or “width” (xdirection).
-
fill_alpha¶ property type:
NumberSpecThe fill alpha values for the band.
-
line_alpha¶ property type:
NumberSpecThe line alpha values for the band.
-
line_dash¶ property type:
DashPatternThe line dash values for the band.
-
line_width¶ property type:
NumberSpecThe line width values for the band.
-
lower¶ property type:
DistanceSpecThe coordinates of the lower portion of the filled area band.
-
lower_units¶ property type:
Enum(SpatialUnits)
-
source¶ property type:
Instance(DataSource)Local data source to use when rendering annotations on the plot.
-
upper¶ property type:
DistanceSpecThe coordinations of the upper portion of the filled area band.
-
upper_units¶ property type:
Enum(SpatialUnits)
-
-
class
BoxAnnotation(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a shaded rectangular region as an annotation.
-
bottom¶ property type:
Either(Auto,NumberSpec)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¶ property type:
Enum(SpatialUnits)The unit type for the bottom attribute. Interpreted as “data space” units by default.
-
fill_alpha¶ property type:
NumberSpecThe fill alpha values for the box.
-
left¶ property type:
Either(Auto,NumberSpec)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¶ property type:
Enum(SpatialUnits)The unit type for the left attribute. Interpreted as “data space” units by default.
-
line_alpha¶ property type:
NumberSpecThe line alpha values for the box.
-
line_dash¶ property type:
DashPatternThe line dash values for the box.
-
line_width¶ property type:
NumberSpecThe line width values for the box.
-
render_mode¶ property type:
Enum(RenderMode)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¶ property type:
Either(Auto,NumberSpec)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¶ property type:
Enum(SpatialUnits)The unit type for the right attribute. Interpreted as “data space” units by default.
-
top¶ property type:
Either(Auto,NumberSpec)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¶ property type:
Enum(SpatialUnits)The unit type for the top attribute. Interpreted as “data space” units by default.
-
-
class
ColorBar(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a color bar based on a color mapper.
-
background_fill_alpha¶ property type:
NumberSpecThe fill alpha for the color bar background style.
-
bar_line_alpha¶ property type:
NumberSpecThe line alpha for the color scale bar outline.
-
bar_line_dash¶ property type:
DashPatternThe line dash for the color scale bar outline.
-
bar_line_width¶ property type:
NumberSpecThe line width for the color scale bar outline.
-
border_line_alpha¶ property type:
NumberSpecThe line alpha for the color bar border outline.
-
border_line_dash¶ property type:
DashPatternThe line dash for the color bar border outline.
-
border_line_width¶ property type:
NumberSpecThe line width for the color bar border outline.
-
color_mapper¶ property type:
Instance(ContinuousColorMapper)A continuous color mapper containing a color palette to render.
Warning
If the low and high attributes of the ColorMapper aren’t set, ticks and tick labels won’t be rendered. Additionally, if a LogTicker is passed to the ticker argument and either or both of the logarithms of low and high values of the color_mapper are non-numeric (i.e. low=0), the tick and tick labels won’t be rendered.
-
formatter¶ property type:
Instance(TickFormatter)A TickFormatter to use for formatting the visual appearance of ticks.
-
height¶ property type:
Either(Auto,Int)The height (in pixels) that the color scale should occupy.
-
label_standoff¶ property type:
IntThe distance (in pixels) to separate the tick labels from the color bar.
-
location¶ property type:
Either(Enum(LegendLocation),Tuple(Float,Float) )The location where the color bar 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).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¶ property type:
Dict(Either(Float,String),String)Provide explicit tick label values for specific tick locations that override normal formatting.
-
major_label_text_alpha¶ property type:
NumberSpecThe text alpha of the major tick labels.
-
major_label_text_baseline¶ property type:
Enum(TextBaseline)The text baseline of the major tick labels.
-
major_label_text_font_size¶ property type:
FontSizeSpecThe text font size of the major tick labels.
-
major_label_text_font_style¶ property type:
Enum(FontStyle)The text font style of the major tick labels.
-
major_tick_in¶ property type:
IntThe distance (in pixels) that major ticks should extend into the main plot area.
-
major_tick_line_alpha¶ property type:
NumberSpecThe line alpha of the major ticks.
-
major_tick_line_dash¶ property type:
DashPatternThe line dash of the major ticks.
-
major_tick_line_width¶ property type:
NumberSpecThe line width of the major ticks.
-
major_tick_out¶ property type:
IntThe distance (in pixels) that major ticks should extend out of the main plot area.
-
minor_tick_in¶ property type:
IntThe distance (in pixels) that minor ticks should extend into the main plot area.
-
minor_tick_line_alpha¶ property type:
NumberSpecThe line alpha of the minor ticks.
-
minor_tick_line_dash¶ property type:
DashPatternThe line dash of the minor ticks.
-
minor_tick_line_width¶ property type:
NumberSpecThe line width of the minor ticks.
-
minor_tick_out¶ property type:
IntThe distance (in pixels) that major ticks should extend out of the main plot area.
-
orientation¶ property type:
Enum(Orientation)Whether the color bar should be oriented vertically or horizontally.
-
padding¶ property type:
IntAmount of padding (in pixels) between the color scale and color bar border.
-
ticker¶ property type:
Instance(ContinuousTicker)A Ticker to use for computing locations of axis components.
-
title_standoff¶ property type:
IntThe distance (in pixels) to separate the title from the color bar.
-
title_text_alpha¶ property type:
NumberSpecThe text alpha values for the title text.
-
title_text_baseline¶ property type:
Enum(TextBaseline)The text baseline values for the title text.
-
title_text_font_size¶ property type:
FontSizeSpecThe text font size values for the title text.
-
-
class
Label(**kwargs)[source]¶ Bases:
bokeh.models.annotations.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.
-
angle¶ property type:
AngleThe angle to rotate the text, as measured from the horizontal.
Warning
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¶ property type:
Enum(AngleUnits)Acceptable values for units are
"rad"and"deg"
-
background_fill_alpha¶ property type:
NumberSpecThe fill alpha values for the text bounding box.
-
border_line_alpha¶ property type:
NumberSpecThe line alpha values for the text bounding box.
-
border_line_dash¶ property type:
DashPatternThe line dash values for the text bounding box.
-
border_line_width¶ property type:
NumberSpecThe line width values for the text bounding box.
-
text_alpha¶ property type:
NumberSpecThe text alpha values for the text.
-
text_baseline¶ property type:
Enum(TextBaseline)The text baseline values for the text.
-
text_font_size¶ property type:
FontSizeSpecThe text font size values for the text.
-
x¶ property type:
FloatThe 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¶ property type:
FloatOffset 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¶ property type:
StringA particular (named) x-range to use for computing screen location when rendering an annotation on the plot. If unset, use the default x-range.
-
x_units¶ property type:
Enum(SpatialUnits)The unit type for the x attribute. Interpreted as “data space” units by default.
-
y¶ property type:
FloatThe 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¶ property type:
FloatOffset 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¶ property type:
StringA particular (named) y-range to use for computing screen location when rendering an annotation on the plot. If unset, use the default y-range.
-
y_units¶ property type:
Enum(SpatialUnits)The unit type for the y attribute. Interpreted as “data space” units by default.
-
-
class
LabelSet(**kwargs)[source]¶ Bases:
bokeh.models.annotations.TextAnnotationRender 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.-
angle¶ property type:
AngleSpecThe angles to rotate the text, as measured from the horizontal.
Warning
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¶ property type:
Enum(AngleUnits)
-
background_fill_alpha¶ property type:
NumberSpecThe fill alpha values for the text bounding box.
-
border_line_alpha¶ property type:
NumberSpecThe line alpha values for the text bounding box.
-
border_line_dash¶ property type:
DashPatternThe line dash values for the text bounding box.
-
border_line_width¶ property type:
NumberSpecThe line width values for the text bounding box.
-
source¶ property type:
Instance(DataSource)Local data source to use when rendering annotations on the plot.
-
text¶ property type:
StringSpecThe text values to render.
-
text_alpha¶ property type:
NumberSpecThe text alpha values for the text.
-
text_baseline¶ property type:
Enum(TextBaseline)The text baseline values for the text.
-
text_font_size¶ property type:
FontSizeSpecThe text font size values for the text.
-
x¶ property type:
NumberSpecThe x-coordinates to locate the text anchors.
-
x_offset¶ property type:
NumberSpecOffset 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¶ property type:
StringA particular (named) x-range to use for computing screen locations when rendering annotations on the plot. If unset, use the default x-range.
-
x_units¶ property type:
Enum(SpatialUnits)The unit type for the xs attribute. Interpreted as “data space” units by default.
-
y¶ property type:
NumberSpecThe y-coordinates to locate the text anchors.
-
y_offset¶ property type:
NumberSpecOffset 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¶ property type:
StringA particular (named) y-range to use for computing screen locations when rendering annotations on the plot. If unset, use the default y-range.
-
y_units¶ property type:
Enum(SpatialUnits)The unit type for the ys attribute. Interpreted as “data space” units by default.
-
-
class
Legend(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender informational legends for a plot.
-
background_fill_alpha¶ property type:
NumberSpecThe fill alpha for the legend background style.
-
border_line_alpha¶ property type:
NumberSpecThe line alpha for the legend border outline.
-
border_line_dash¶ property type:
DashPatternThe line dash for the legend border outline.
-
border_line_width¶ property type:
NumberSpecThe line width for the legend border outline.
-
click_policy¶ property type:
Enum(LegendClickPolicy)Defines what happens when a lengend’s item is clicked.
-
glyph_height¶ property type:
IntThe height (in pixels) that the rendered legend glyph should occupy.
-
inactive_fill_alpha¶ property type:
NumberSpecThe 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¶ property type:
ColorSpecThe 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¶ property type:
List(Instance(LegendItem) )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¶ property type:
IntThe minimum height (in pixels) of the area that legend labels should occupy.
-
label_standoff¶ property type:
IntThe distance (in pixels) to separate the label from its associated glyph.
-
label_text_alpha¶ property type:
NumberSpecThe text alpha for the legend labels.
-
label_text_baseline¶ property type:
Enum(TextBaseline)The text baseline for the legend labels.
-
label_text_font_size¶ property type:
FontSizeSpecThe text font size for the legend labels.
-
label_width¶ property type:
IntThe minimum width (in pixels) of the area that legend labels should occupy.
-
location¶ property type:
Either(Enum(LegendLocation),Tuple(Float,Float) )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).
-
orientation¶ property type:
Enum(Orientation)Whether the legend entries should be placed vertically or horizontally when they are drawn.
-
-
class
LegendItem(*args, **kwargs)[source]¶ Bases:
bokeh.model.Model-
index¶ property type:
IntThe 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 numbner as the index in all cases.
-
label¶ property type:
StringSpecA 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.
-
renderers¶ property type:
List(Instance(GlyphRenderer) )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.
-
-
class
PolyAnnotation(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a shaded polygonal region as an annotation.
-
fill_alpha¶ property type:
NumberSpecThe fill alpha values for the polygon.
-
line_alpha¶ property type:
NumberSpecThe line alpha values for the polygon.
-
line_dash¶ property type:
DashPatternThe line dash values for the polygon.
-
line_width¶ property type:
NumberSpecThe line width values for the polygon.
-
x_range_name¶ property type:
StringA particular (named) x-range to use for computing screen locations when rendering box annotations on the plot. If unset, use the default x-range.
-
xs_units¶ property type:
Enum(SpatialUnits)The unit type for the xs attribute. Interpreted as “data space” units by default.
-
y_range_name¶ property type:
StringA particular (named) y-range to use for computing screen locations when rendering box annotations on the plot. If unset, use the default y-range.
-
ys_units¶ property type:
Enum(SpatialUnits)The unit type for the ys attribute. Interpreted as “data space” units by default.
-
-
class
Slope(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a sloped line as an annotation.
-
line_alpha¶ property type:
NumberSpecThe line alpha values for the line.
-
line_dash¶ property type:
DashPatternThe line dash values for the line.
-
line_width¶ property type:
NumberSpecThe line width values for the line.
-
-
class
Span(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a horizontal or vertical line span.
-
dimension¶ property type:
Enum(Dimension)The direction of the span can be specified by setting this property to “height” (
ydirection) or “width” (xdirection).
-
line_alpha¶ property type:
NumberSpecThe line alpha values for the span.
-
line_dash¶ property type:
DashPatternThe line dash values for the span.
-
line_width¶ property type:
NumberSpecThe line width values for the span.
-
location¶ property type:
FloatThe location of the span, along
dimension.Datetime values are also accepted, but note that they are immediately converted to milliseconds-since-epoch.
-
location_units¶ property type:
Enum(SpatialUnits)The unit type for the location attribute. Interpreted as “data space” units by default.
-
render_mode¶ property type:
Enum(RenderMode)Specifies whether the span 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”
-
-
class
TextAnnotation(**kwargs)[source]¶ Bases:
bokeh.models.annotations.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.
-
render_mode¶ property type:
Enum(RenderMode)Specifies whether the text is rendered as a canvas element or as an css element overlaid on the canvas. The default mode is “canvas”.
Note
The CSS labels won’t be present in the output using the “save” tool.
Warning
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.
-
-
class
Title(**kwargs)[source]¶ Bases:
bokeh.models.annotations.TextAnnotationRender a single title box as an annotation.
-
align¶ property type:
Enum(TextAlign)Aligment of the text in its enclosing space, along the direction of the text.
-
background_fill_alpha¶ property type:
NumberSpecThe fill alpha values for the text bounding box.
-
border_line_alpha¶ property type:
NumberSpecThe line alpha values for the text bounding box.
-
border_line_dash¶ property type:
DashPatternThe line dash values for the text bounding box.
-
border_line_width¶ property type:
NumberSpecThe line width values for the text bounding box.
-
offset¶ property type:
FloatOffset 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
-
text_alpha¶ property type:
NumberSpecAn alpha value to use to fill text with.
Acceptable values are floating point numbers between 0 (transparent) and 1 (opaque).
-
text_color¶ property type:
ColorSpecA color to use to fill text with.
Acceptable values are:
- any of the 147 named CSS colors, e.g
'green','indigo' - an RGB(A) hex value, e.g.,
'#FF0000','#44444444' - 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..255 and a is between 0..1
- any of the 147 named CSS colors, e.g
-
text_font¶ property type:
StringName of a font to use for rendering text, e.g.,
'times','helvetica'.
-
text_font_size¶ property type:
FontSizeSpec
-
text_font_style¶ property type:
Enum(FontStyle)A style to use for rendering text.
Acceptable values are:
'normal'normal text'italic'italic text'bold'bold text
-
vertical_align¶ property type:
Enum(VerticalAlign)Aligment of the text in its enclosing space, across the direction of the text.
-
-
class
Tooltip(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a tooltip.
Note
This model is currently managed by BokehJS and is not useful directly from python.
-
attachment¶ property type:
Enum(TooltipAttachment)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.
-
-
class
Whisker(**kwargs)[source]¶ Bases:
bokeh.models.annotations.AnnotationRender a whisker along a dimension.
-
base¶ property type:
DistanceSpecThe orthogonal coordinates of the upper and lower values.
-
base_units¶ property type:
Enum(SpatialUnits)
-
dimension¶ property type:
Enum(Dimension)The direction of the whisker can be specified by setting this property to “height” (
ydirection) or “width” (xdirection).
-
line_alpha¶ property type:
NumberSpecThe line alpha values for the whisker body.
-
line_dash¶ property type:
DashPatternThe line dash values for the whisker body.
-
line_width¶ property type:
NumberSpecThe line width values for the whisker body.
-
lower¶ property type:
DistanceSpecThe coordinates of the lower end of the whiskers.
-
lower_units¶ property type:
Enum(SpatialUnits)
-
source¶ property type:
Instance(DataSource)Local data source to use when rendering annotations on the plot.
-
upper¶ property type:
DistanceSpecThe coordinations of the upper end of the whiskers.
-
upper_units¶ property type:
Enum(SpatialUnits)
-