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.

plot

property type: Instance(Plot)

The plot to which this annotation is attached.

[
  {
    "attributes": {
      "doc": null,
      "id": "2d900c51-e5b4-47ef-9685-f330366a5faa",
      "name": null,
      "plot": null,
      "tags": []
    },
    "id": "2d900c51-e5b4-47ef-9685-f330366a5faa",
    "type": "Annotation"
  }
]
class BoxAnnotation(**kwargs)

Bases: bokeh.models.annotations.Annotation

Render an annotation box “shade” thing

bottom

property type: Either(Auto, NumberSpec(‘bottom’))

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

bottom_units

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

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

fill_alpha

property type: NumberSpec(1.0)

The fill alpha values for the shades.

fill_color

property type: ColorSpec(‘gray’)

The fill color values for the shades.

left

property type: Either(Auto, NumberSpec(‘left’))

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

left_units

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

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

level

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

Specifies the level in which to render the box annotation.

line_alpha

property type: NumberSpec(1.0)

The line alpha values for the shades.

line_cap

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

The line cap values for the shades.

line_color

property type: ColorSpec(‘black’)

The line color values for the shades.

line_dash

property type: DashPattern

The line dash values for the shades.

line_dash_offset

property type: Int

The line dash offset values for the shades.

line_join

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

The line join values for the shades.

line_width

property type: NumberSpec(1)

The line width values for the shades.

right

property type: Either(Auto, NumberSpec(‘right’))

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

right_units

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

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

top

property type: Either(Auto, NumberSpec(‘top’))

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

top_units

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

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

x_range_name

property type: 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: 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.

[
  {
    "attributes": {
      "bottom": "auto",
      "bottom_units": "data",
      "doc": null,
      "fill_alpha": {
        "value": 1.0
      },
      "fill_color": {
        "value": "gray"
      },
      "id": "90563f63-b2f2-4cf6-ab50-264b23e9804b",
      "left": "auto",
      "left_units": "data",
      "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
      },
      "name": null,
      "plot": null,
      "right": "auto",
      "right_units": "data",
      "tags": [],
      "top": "auto",
      "top_units": "data",
      "x_range_name": "default",
      "y_range_name": "default"
    },
    "id": "90563f63-b2f2-4cf6-ab50-264b23e9804b",
    "type": "BoxAnnotation"
  }
]
class Legend(**kwargs)

Bases: bokeh.models.annotations.Annotation

Render informational legends for a plot.

background_fill_alpha

property type: NumberSpec(1.0)

The fill alpha for the legend background style.

background_fill_color

property type: ColorSpec(‘gray’)

The fill color for the legend background style.

border_line_alpha

property type: NumberSpec(1.0)

The line alpha for the legend border outline.

border_line_cap

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

The line cap for the legend border outline.

border_line_color

property type: ColorSpec(‘black’)

The line color for the legend border outline.

border_line_dash

property type: DashPattern

The line dash for the legend border outline.

border_line_dash_offset

property type: Int

The line dash offset for the legend border outline.

border_line_join

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

The line join for the legend border outline.

border_line_width

property type: NumberSpec(1)

The line width for the legend border outline.

glyph_height

property type: Int

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

glyph_width

property type: Int

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

label_height

property type: Int

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

label_standoff

property type: Int

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

label_text_align

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

The text align for the legend labels.

label_text_alpha

property type: NumberSpec(1.0)

The text alpha for the legend labels.

label_text_baseline

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

The text baseline for the legend labels.

label_text_color

property type: ColorSpec(‘#444444’)

The text color for the legend labels.

label_text_font

property type: String

The text font for the legend labels.

label_text_font_size

property type: FontSizeSpec(‘12pt’)

The text font size for the legend labels.

label_text_font_style

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

The text font style for the legend labels.

label_width

property type: Int

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

legend_padding

property type: Int

Amount of padding around the legend.

legend_spacing

property type: Int

Amount of spacing between legend entries.

legends

property type: 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, but note that if a dict is used, the order of the legend entries is unspecified.

orientation

property type: Enum(‘top_right’, ‘top_left’, ‘bottom_left’, ‘bottom_right’)

The location where the legend should draw itself.

[
  {
    "attributes": {
      "background_fill_alpha": {
        "value": 1.0
      },
      "background_fill_color": {
        "value": "gray"
      },
      "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
      },
      "doc": null,
      "glyph_height": 20,
      "glyph_width": 20,
      "id": "54e567b3-2efa-412e-a329-30328e47958a",
      "label_height": 20,
      "label_standoff": 15,
      "label_text_align": "left",
      "label_text_alpha": {
        "value": 1.0
      },
      "label_text_baseline": "bottom",
      "label_text_color": {
        "value": "#444444"
      },
      "label_text_font": "Helvetica",
      "label_text_font_size": {
        "field": "12pt"
      },
      "label_text_font_style": "normal",
      "label_width": 50,
      "legend_padding": 10,
      "legend_spacing": 3,
      "legends": [],
      "name": null,
      "orientation": "top_right",
      "plot": null,
      "tags": []
    },
    "id": "54e567b3-2efa-412e-a329-30328e47958a",
    "type": "Legend"
  }
]