bokeh.models.annotations

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

class Annotation(**kwargs)

Bases: bokeh.models.renderers.Renderer

Base class for annotation models.

level

property type: level:Enum(‘image’, ‘underlay’, ‘glyph’, ‘annotation’, ‘overlay’, ‘tool’)

Specifies the level in which to render the annotation.

plot

property type: plot:Instance(Plot)

The plot to which this annotation is attached.

JSON Prototype
{
  "id": "26762969-7513-478b-aa92-fe27ee389b46",
  "level": "annotation",
  "name": null,
  "plot": null,
  "tags": []
}
class BoxAnnotation(**kwargs)

Bases: bokeh.models.annotations.Annotation

Render a shaded rectangular region as an annotation.

bottom

property type: bottom:Either(Auto, NumberSpec(String, Dict(String, Either(String, Float)), Float))

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

bottom_units

property type: bottom_units:Enum(‘screen’, ‘data’)

The unit type for the bottom attribute. Interpreted as “data space” units by default.

fill_alpha

property type: fill_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The fill alpha values for the box.

fill_color

property type: fill_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The fill color values for the box.

left

property type: left:Either(Auto, NumberSpec(String, Dict(String, Either(String, Float)), Float))

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

left_units

property type: left_units:Enum(‘screen’, ‘data’)

The unit type for the left attribute. Interpreted as “data space” units by default.

line_alpha

property type: line_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line alpha values for the box.

line_cap

property type: line_cap:Enum(‘butt’, ‘round’, ‘square’)

The line cap values for the box.

line_color

property type: line_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The line color values for the box.

line_dash

property type: line_dash:DashPattern

The line dash values for the box.

line_dash_offset

property type: line_dash_offset:Int

The line dash offset values for the box.

line_join

property type: line_join:Enum(‘miter’, ‘round’, ‘bevel’)

The line join values for the box.

line_width

property type: line_width:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line width values for the box.

render_mode

property type: render_mode:Enum(‘canvas’, ‘css’)

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: right:Either(Auto, NumberSpec(String, Dict(String, Either(String, Float)), Float))

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

right_units

property type: right_units:Enum(‘screen’, ‘data’)

The unit type for the right attribute. Interpreted as “data space” units by default.

top

property type: top:Either(Auto, NumberSpec(String, Dict(String, Either(String, Float)), Float))

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

top_units

property type: top_units:Enum(‘screen’, ‘data’)

The unit type for the top attribute. Interpreted as “data space” units by default.

x_range_name

property type: x_range_name:String

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

y_range_name

property type: y_range_name:String

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

JSON Prototype
{
  "bottom": null,
  "bottom_units": "data",
  "fill_alpha": {
    "value": 0.4
  },
  "fill_color": {
    "value": "#fff9ba"
  },
  "id": "86c464f9-2615-4c66-bc14-0e014774648a",
  "left": null,
  "left_units": "data",
  "level": "annotation",
  "line_alpha": {
    "value": 0.3
  },
  "line_cap": "butt",
  "line_color": {
    "value": "#cccccc"
  },
  "line_dash": [],
  "line_dash_offset": 0,
  "line_join": "miter",
  "line_width": {
    "value": 1
  },
  "name": null,
  "plot": null,
  "render_mode": "canvas",
  "right": null,
  "right_units": "data",
  "tags": [],
  "top": null,
  "top_units": "data",
  "x_range_name": "default",
  "y_range_name": "default"
}
class Legend(**kwargs)

Bases: bokeh.models.annotations.Annotation

Render informational legends for a plot.

background_fill_alpha

property type: background_fill_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The fill alpha for the legend background style.

background_fill_color

property type: background_fill_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The fill color for the legend background style.

border_line_alpha

property type: border_line_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line alpha for the legend border outline.

border_line_cap

property type: border_line_cap:Enum(‘butt’, ‘round’, ‘square’)

The line cap for the legend border outline.

border_line_color

property type: border_line_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The line color for the legend border outline.

border_line_dash

property type: border_line_dash:DashPattern

The line dash for the legend border outline.

border_line_dash_offset

property type: border_line_dash_offset:Int

The line dash offset for the legend border outline.

border_line_join

property type: border_line_join:Enum(‘miter’, ‘round’, ‘bevel’)

The line join for the legend border outline.

border_line_width

property type: border_line_width:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line width for the legend border outline.

glyph_height

property type: glyph_height:Int

The height (in pixels) that the rendered legend glyph should occupy.

glyph_width

property type: glyph_width:Int

The width (in pixels) that the rendered legend glyph should occupy.

label_height

property type: label_height:Int

The height (in pixels) of the area that legend labels should occupy.

label_standoff

property type: label_standoff:Int

The distance (in pixels) to separate the label from its associated glyph.

label_text_align

property type: label_text_align:Enum(‘left’, ‘right’, ‘center’)

The text align for the legend labels.

label_text_alpha

property type: label_text_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The text alpha for the legend labels.

label_text_baseline

property type: label_text_baseline:Enum(‘top’, ‘middle’, ‘bottom’, ‘alphabetic’, ‘hanging’)

The text baseline for the legend labels.

label_text_color

property type: label_text_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The text color for the legend labels.

label_text_font

property type: label_text_font:String

The text font for the legend labels.

label_text_font_size

property type: label_text_font_size:FontSizeSpec(String, Dict(String, Either(String, List(String))), List(String))

The text font size for the legend labels.

label_text_font_style

property type: label_text_font_style:Enum(‘normal’, ‘italic’, ‘bold’)

The text font style for the legend labels.

label_width

property type: label_width:Int

The width (in pixels) of the area that legend labels should occupy.

legend_padding

property type: legend_padding:Int

Amount of padding around the legend.

legend_spacing

property type: legend_spacing:Int

Amount of spacing between legend entries.

legends

property type: legends:List(Tuple(String, List(Instance(GlyphRenderer))))

A list of tuples that maps text labels to the legend to corresponding renderers that should draw sample representations for those labels.

Note

The legends attribute may also be set from a dict or OrderedDict. If a dict is used, the order of the legend entries is unspecified.

location

property type: location:Either(Enum(‘top_left’, ‘top_center’, ‘top_right’, ‘right_center’, ‘bottom_right’, ‘bottom_center’, ‘bottom_left’, ‘left_center’, ‘center’), 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

Deprecated in Bokeh 0.11; please use Legend.location instead.

JSON Prototype
{
  "background_fill_alpha": {
    "value": 1.0
  },
  "background_fill_color": {
    "value": "#ffffff"
  },
  "border_line_alpha": {
    "value": 1.0
  },
  "border_line_cap": "butt",
  "border_line_color": {
    "value": "black"
  },
  "border_line_dash": [],
  "border_line_dash_offset": 0,
  "border_line_join": "miter",
  "border_line_width": {
    "value": 1
  },
  "glyph_height": 20,
  "glyph_width": 20,
  "id": "4c4e6d07-c6e9-4fd5-a831-c2cb9095a5c3",
  "label_height": 20,
  "label_standoff": 15,
  "label_text_align": "left",
  "label_text_alpha": {
    "value": 1.0
  },
  "label_text_baseline": "middle",
  "label_text_color": {
    "value": "#444444"
  },
  "label_text_font": "helvetica",
  "label_text_font_size": {
    "value": "10pt"
  },
  "label_text_font_style": "normal",
  "label_width": 50,
  "legend_padding": 10,
  "legend_spacing": 3,
  "legends": [],
  "level": "annotation",
  "location": "top_right",
  "name": null,
  "plot": null,
  "tags": []
}
class PolyAnnotation(**kwargs)

Bases: bokeh.models.annotations.Annotation

Render a shaded polygonal region as an annotation.

fill_alpha

property type: fill_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The fill alpha values for the polygon.

fill_color

property type: fill_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The fill color values for the polygon.

line_alpha

property type: line_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line alpha values for the polygon.

line_cap

property type: line_cap:Enum(‘butt’, ‘round’, ‘square’)

The line cap values for the polygon.

line_color

property type: line_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The line color values for the polygon.

line_dash

property type: line_dash:DashPattern

The line dash values for the polygon.

line_dash_offset

property type: line_dash_offset:Int

The line dash offset values for the polygon.

line_join

property type: line_join:Enum(‘miter’, ‘round’, ‘bevel’)

The line join values for the polygon.

line_width

property type: line_width:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line width values for the polygon.

x_range_name

property type: x_range_name:String

A 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

property type: xs:Seq(Float)

The x-coordinates of the region to draw.

xs_units

property type: xs_units:Enum(‘screen’, ‘data’)

The unit type for the xs attribute. Interpreted as “data space” units by default.

y_range_name

property type: y_range_name:String

A 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

property type: ys:Seq(Float)

The y-coordinates of the region to draw.

ys_units

property type: ys_units:Enum(‘screen’, ‘data’)

The unit type for the ys attribute. Interpreted as “data space” units by default.

JSON Prototype
{
  "fill_alpha": {
    "value": 0.4
  },
  "fill_color": {
    "value": "#fff9ba"
  },
  "id": "7766e8e4-2aa4-4a23-b336-0b1bda811c23",
  "level": "annotation",
  "line_alpha": {
    "value": 0.3
  },
  "line_cap": "butt",
  "line_color": {
    "value": "#cccccc"
  },
  "line_dash": [],
  "line_dash_offset": 0,
  "line_join": "miter",
  "line_width": {
    "value": 1
  },
  "name": null,
  "plot": null,
  "tags": [],
  "x_range_name": "default",
  "xs": [],
  "xs_units": "data",
  "y_range_name": "default",
  "ys": [],
  "ys_units": "data"
}
class Span(**kwargs)

Bases: bokeh.models.annotations.Annotation

Render a horizontal or vertical line span.

dimension

property type: dimension:Enum(‘width’, ‘height’, ‘x’, ‘y’)

The direction of the span.

line_alpha

property type: line_alpha:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line alpha values for the span.

line_cap

property type: line_cap:Enum(‘butt’, ‘round’, ‘square’)

The line cap values for the span.

line_color

property type: line_color:ColorSpec(String, Dict(String, Either(String, Color)), Color)

The line color values for the span.

line_dash

property type: line_dash:DashPattern

The line dash values for the span.

line_dash_offset

property type: line_dash_offset:Int

The line dash offset values for the span.

line_join

property type: line_join:Enum(‘miter’, ‘round’, ‘bevel’)

The line join values for the span.

line_width

property type: line_width:NumberSpec(String, Dict(String, Either(String, Float)), Float)

The line width values for the span.

location

property type: location:Float

The location of the span, along dimension.

location_units

property type: location_units:Enum(‘screen’, ‘data’)

The unit type for the location attribute. Interpreted as “data space” units by default.

render_mode

property type: render_mode:Enum(‘canvas’, ‘css’)

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”

x_range_name

property type: x_range_name:String

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

y_range_name

property type: y_range_name:String

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

JSON Prototype
{
  "dimension": "width",
  "id": "3f3bc111-33ee-4735-a316-1391b0e9c231",
  "level": "annotation",
  "line_alpha": {
    "value": 1.0
  },
  "line_cap": "butt",
  "line_color": {
    "value": "black"
  },
  "line_dash": [],
  "line_dash_offset": 0,
  "line_join": "miter",
  "line_width": {
    "value": 1
  },
  "location": null,
  "location_units": "data",
  "name": null,
  "plot": null,
  "render_mode": "canvas",
  "tags": [],
  "x_range_name": "default",
  "y_range_name": "default"
}
class Tooltip(**kwargs)

Bases: bokeh.models.annotations.Annotation

Render a tooltip.

Note

This model is currently managed by BokehJS and is not useful directly from python.

inner_only

property type: inner_only:Bool

Whether to display outside a central plot frame area.

side

property type: side:Either(Auto, Enum(‘left’, ‘right’))

Whether the tooltip should display to the left or right off the cursor position, or if it should be automatically placed.

JSON Prototype
{
  "id": "49cca2a6-0650-4fe8-9cb2-df764af688a7",
  "inner_only": true,
  "level": "overlay",
  "name": null,
  "plot": null,
  "side": "auto",
  "tags": []
}