bokeh.models.plots

Models for representing top-level plot objects.

class GridPlot(**kwargs)

Bases: bokeh.models.plots.Plot

A 2D grid of plots rendered on separate canvases in an HTML table.

column(col)

Return a given column of plots from this GridPlot.

Parameters:col (int) – index of the column to return
Returns:column of plots
Return type:seq[Plot]
row(row)

Return a given row of plots from this GridPlot.

Parameters:rwo (int) – index of the row to return
Returns:row of plots
Return type:seq[Plot]
select(*args, **kwargs)

Query this object and all of its references for objects that match the given selector. See Plot.select for detailed usage infomation.

Returns:seq[PlotObject]
border_space

property type: Int

Distance (in pixels) between adjacent plots.

children

property type: List(List(Instance(Plot)))

An array of plots to display in a grid, given as a list of lists of Plot objects. To leave a position in the grid empty, pass None for that position in the children list.

[
  {
    "attributes": {
      "doc": null,
      "geometries": [],
      "id": "d665128e-6044-46f7-a0fb-be389569d616",
      "name": null,
      "tags": []
    },
    "id": "d665128e-6044-46f7-a0fb-be389569d616",
    "type": "ToolEvents"
  },
  {
    "attributes": {
      "above": [],
      "background_fill": "white",
      "below": [],
      "border_fill": "white",
      "border_space": 0,
      "children": [],
      "disabled": false,
      "doc": null,
      "extra_x_ranges": {},
      "extra_y_ranges": {},
      "h_symmetry": true,
      "id": "8441a720-5259-4f55-a927-30261cc2d49f",
      "left": [],
      "lod_factor": 10,
      "lod_interval": 300,
      "lod_threshold": 2000,
      "lod_timeout": 500,
      "logo": "normal",
      "min_border": 50,
      "min_border_bottom": 50,
      "min_border_left": 50,
      "min_border_right": 50,
      "min_border_top": 50,
      "name": null,
      "outline_line_alpha": {
        "value": 1.0
      },
      "outline_line_cap": "butt",
      "outline_line_color": {
        "value": "black"
      },
      "outline_line_dash": [],
      "outline_line_dash_offset": 0,
      "outline_line_join": "miter",
      "outline_line_width": {
        "value": 1
      },
      "plot_height": 600,
      "plot_width": 600,
      "renderers": [],
      "responsive": false,
      "right": [],
      "tags": [],
      "title": "",
      "title_text_align": "left",
      "title_text_alpha": {
        "value": 1.0
      },
      "title_text_baseline": "bottom",
      "title_text_color": {
        "value": "#444444"
      },
      "title_text_font": "Helvetica",
      "title_text_font_size": {
        "field": "12pt"
      },
      "title_text_font_style": "normal",
      "tool_events": {
        "id": "d665128e-6044-46f7-a0fb-be389569d616",
        "type": "ToolEvents"
      },
      "toolbar_location": "above",
      "tools": [],
      "v_symmetry": false,
      "webgl": false,
      "x_mapper_type": "auto",
      "x_range": null,
      "y_mapper_type": "auto",
      "y_range": null
    },
    "id": "8441a720-5259-4f55-a927-30261cc2d49f",
    "type": "GridPlot"
  }
]
class Plot(**kwargs)

Bases: bokeh.models.widget.Widget

Model representing a plot, containing glyphs, guides, annotations.

add_glyph(source_or_glyph, glyph=None, **kw)

Adds a glyph to the plot with associated data sources and ranges.

This function will take care of creating and configurinf a Glyph object, and then add it to the plot’s list of renderers.

Parameters:
  • source (DataSource) – a data source for the glyphs to all use
  • glyph (Glyph) – the glyph to add to the Plot
Keyword Arguments:
 
  • Any additional keyword arguments are passed on as-is to the
  • Glyph initializer.
Returns:

Glyph

Return type:

glyph

add_layout(obj, place='center')

Adds an object to the plot in a specified place.

Parameters:
  • obj (Renderer) – the object to add to the Plot
  • place (str, optional) – where to add the object (default: ‘center’) Valid places are: ‘left’, ‘right’, ‘above’, ‘below’, ‘center’.
Returns:

None

add_tools(*tools)

Adds an tools to the plot.

Parameters:*tools (Tool) – the tools to add to the Plot
Returns:None
column(col, gridplot)

Return whether this plot is in a given column of a GridPlot.

Parameters:
  • col (int) – index of the column to test
  • gridplot (GridPlot) – the GridPlot to check
Returns:

bool

row(row, gridplot)

Return whether this plot is in a given row of a GridPlot.

Parameters:
  • row (int) – index of the row to test
  • gridplot (GridPlot) – the GridPlot to check
Returns:

bool

select(*args, **kwargs)

Query this object and all of its references for objects that match the given selector.

There are a few different ways to call the select method. The most general is to supply a JSON-like query dictionary as the single argument or as keyword arguments:

Parameters:selector (JSON-like) – some sample text
Keyword Arguments:
 kwargs – query dict key/values as keyword arguments

For convenience, queries on just names can be made by supplying the name string as the single parameter:

Parameters:name (str) – the name to query on

Also queries on just type can be made simply by supplying the PlotObject subclass as the single parameter:

Parameters:type (PlotObject) – the type to query on
Returns:seq[PlotObject]

Examples

# These two are equivalent
p.select({"type": HoverTool})
p.select(HoverTool)

# These two are also equivalent
p.select({"name": "mycircle"})
p.select("mycircle")

# Keyword arguments can be supplied in place of selector dict
p.select({"name": "foo", "type": HoverTool})
p.select(name="foo", type=HoverTool)
above

property type: List(Instance(Renderer))

A list of renderers to occupy the area above of the plot.

background_fill

property type: Color

below

property type: List(Instance(Renderer))

A list of renderers to occupy the area below of the plot.

border_fill

property type: Color

extra_x_ranges

property type: Dict(String, Instance(Range1d))

Additional named ranges to make available for mapping x-coordinates.

This is useful for adding additional axes.

extra_y_ranges

property type: Dict(String, Instance(Range))

Additional named ranges to make available for mapping y-coordinates.

This is useful for adding additional axes.

h_symmetry

property type: Bool

Whether the total horizontal padding on both sides of the plot will be made equal (the left or right padding amount, whichever is larger).

left

property type: List(Instance(Renderer))

A list of renderers to occupy the area to the left of the plot.

lod_factor

property type: Int

Decimation factor to use when applying level-of-detail decimation.

lod_interval

property type: Int

Interval (in ms) during which an interactive tool event will enable level-of-detail downsampling.

lod_threshold

property type: Int

A number of data points, above which level-of-detail downsampling may be performed by glyph renderers. Set to None to disable any level-of-detail downsampling.

lod_timeout

property type: Int

Timeout (in ms) for checking whether interactive tool events are still occurring. Once level-of-detail mode is enabled, a check is made every lod_timeout ms. If no interactive tool events have happened, level-of-detail mode is disabled.

property type: Enum(‘normal’, ‘grey’)

What version of the Bokeh logo to display on the toolbar. If set to None, no logo will be displayed.

min_border

property type: Int

A convenience property to set all all the min_X_border properties to the same value. If an individual border property is explicitly set, it will override min_border.

min_border_bottom

property type: Int

Minimum size in pixels of the padding region below the bottom of the central plot region.

Note

This is a minimum. The padding region may expand as needed to accommodate titles or axes, etc.

min_border_left

property type: Int

Minimum size in pixels of the padding region to the left of the central plot region.

Note

This is a minimum. The padding region may expand as needed to accommodate titles or axes, etc.

min_border_right

property type: Int

Minimum size in pixels of the padding region to the right of the central plot region.

Note

This is a minimum. The padding region may expand as needed to accommodate titles or axes, etc.

min_border_top

property type: Int

Minimum size in pixels of the padding region above the top of the central plot region.

Note

This is a minimum. The padding region may expand as needed to accommodate titles or axes, etc.

outline_line_alpha

property type: NumberSpec(1.0)

The line alpha for the plot border outline.

outline_line_cap

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

The line cap for the plot border outline.

outline_line_color

property type: ColorSpec(‘black’)

The line color for the plot border outline.

outline_line_dash

property type: DashPattern

The line dash for the plot border outline.

outline_line_dash_offset

property type: Int

The line dash offset for the plot border outline.

outline_line_join

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

The line join for the plot border outline.

outline_line_width

property type: NumberSpec(1)

The line width for the plot border outline.

plot_height

property type: Int

Total height of the entire plot (including any axes, titles, border padding, etc.)

Note

This corresponds directly to the height of the HTML canvas that will be used.

plot_width

property type: Int

Total width of the entire plot (including any axes, titles, border padding, etc.)

Note

This corresponds directly to the width of the HTML canvas that will be used.

renderers

property type: List(Instance(Renderer))

A list of all renderers for this plot, including guides and annotations in addition to glyphs and markers.

This property can be manipulated by hand, but the add_glyph and add_layout methods are recommended to help make sure all necessary setup is performed.

responsive

property type: Bool

If True, the plot will automatically resize based on the size of its container. The aspect ratio of the plot will be preserved, but plot_width and plot_height will act only to set the initial aspect ratio. .. warning:

The responsive setting is known not to work with HBox layout and may not work
in combination with other widgets or layouts.
right

property type: List(Instance(Renderer))

A list of renderers to occupy the area to the right of the plot.

title

property type: String

A title for the plot.

title_text_align

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

The text align for the plot title.

title_text_alpha

property type: NumberSpec(1.0)

The text alpha for the plot title.

title_text_baseline

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

The text baseline for the plot title.

title_text_color

property type: ColorSpec(‘#444444’)

The text color for the plot title.

title_text_font

property type: String

The text font for the plot title.

title_text_font_size

property type: FontSizeSpec(‘12pt’)

The text font size for the plot title.

title_text_font_style

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

The text font style for the plot title.

tool_events

property type: Instance(Tool:class:~bokeh.properties.Events)

A ToolEvents object to share and report tool events.

toolbar_location

property type: Enum(‘above’, ‘below’, ‘left’, ‘right’)

Where the toolbar will be located. If set to None, no toolbar will be attached to the plot.

tools

property type: List(Instance(Tool))

A list of tools to add to the plot.

v_symmetry

property type: Bool

Whether the total vertical padding on both sides of the plot will be made equal (the top or bottom padding amount, whichever is larger).

webgl

property type: Bool

Whether WebGL is enabled for this plot. If True, the glyphs that support this will render via WebGL instead of the 2D canvas.

x_mapper_type

property type: Either(Auto, String)

What kind of mapper to use to convert x-coordinates in data space into x-coordinates in screen space.

Typically this can be determined automatically, but this property can be useful to, e.g., show datetime values as floating point “seconds since epoch” instead of formatted dates.

x_range

property type: Instance(Range)

The (default) data range of the horizontal dimension of the plot.

y_mapper_type

property type: Either(Auto, String)

What kind of mapper to use to convert y-coordinates in data space into y-coordinates in screen space.

Typically this can be determined automatically, but this property can be useful to, e.g., show datetime values as floating point “seconds since epoch” instead of formatted dates

y_range

property type: Instance(Range)

The (default) data range of the vertical dimension of the plot.

[
  {
    "attributes": {
      "doc": null,
      "geometries": [],
      "id": "a7c79477-fb2c-4ee4-b49a-0dfb7dc9e522",
      "name": null,
      "tags": []
    },
    "id": "a7c79477-fb2c-4ee4-b49a-0dfb7dc9e522",
    "type": "ToolEvents"
  },
  {
    "attributes": {
      "above": [],
      "background_fill": "white",
      "below": [],
      "border_fill": "white",
      "disabled": false,
      "doc": null,
      "extra_x_ranges": {},
      "extra_y_ranges": {},
      "h_symmetry": true,
      "id": "0d3330d9-87d1-4113-a445-e65acb6c91e7",
      "left": [],
      "lod_factor": 10,
      "lod_interval": 300,
      "lod_threshold": 2000,
      "lod_timeout": 500,
      "logo": "normal",
      "min_border": 50,
      "min_border_bottom": 50,
      "min_border_left": 50,
      "min_border_right": 50,
      "min_border_top": 50,
      "name": null,
      "outline_line_alpha": {
        "value": 1.0
      },
      "outline_line_cap": "butt",
      "outline_line_color": {
        "value": "black"
      },
      "outline_line_dash": [],
      "outline_line_dash_offset": 0,
      "outline_line_join": "miter",
      "outline_line_width": {
        "value": 1
      },
      "plot_height": 600,
      "plot_width": 600,
      "renderers": [],
      "responsive": false,
      "right": [],
      "tags": [],
      "title": "",
      "title_text_align": "left",
      "title_text_alpha": {
        "value": 1.0
      },
      "title_text_baseline": "bottom",
      "title_text_color": {
        "value": "#444444"
      },
      "title_text_font": "Helvetica",
      "title_text_font_size": {
        "field": "12pt"
      },
      "title_text_font_style": "normal",
      "tool_events": {
        "id": "a7c79477-fb2c-4ee4-b49a-0dfb7dc9e522",
        "type": "ToolEvents"
      },
      "toolbar_location": "above",
      "tools": [],
      "v_symmetry": false,
      "webgl": false,
      "x_mapper_type": "auto",
      "x_range": null,
      "y_mapper_type": "auto",
      "y_range": null
    },
    "id": "0d3330d9-87d1-4113-a445-e65acb6c91e7",
    "type": "Plot"
  }
]
class PlotContext(**kwargs)

Bases: bokeh.plot_object.PlotObject

A container for multiple plot objects.

PlotContext objects are a source of confusion. Their purpose is to collect together different top-level objects (e.g., Plot or layout widgets). The reason for this is that different plots may need to share ranges or data sources between them. A PlotContext is a container in which such sharing can occur between the contained objects.

children

property type: List(Instance(PlotObject))

A list of top level objects in this PlotContext container.

[
  {
    "attributes": {
      "children": [],
      "doc": null,
      "id": "3f53cc71-2d53-4cf2-9620-3cebe0beabe3",
      "name": null,
      "tags": []
    },
    "id": "3f53cc71-2d53-4cf2-9620-3cebe0beabe3",
    "type": "PlotContext"
  }
]
class PlotList(**kwargs)

Bases: bokeh.models.plots.PlotContext

[
  {
    "attributes": {
      "children": [],
      "doc": null,
      "id": "8c45444a-8c40-436a-a321-fa4e4a90839d",
      "name": null,
      "tags": []
    },
    "id": "8c45444a-8c40-436a-a321-fa4e4a90839d",
    "type": "PlotList"
  }
]