bokeh.models.plots

Models for representing top-level plot objects.

class Plot(**kwargs)

Bases: bokeh.models.layouts.LayoutDOM

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

add_dynamic_image(image_source, **kw)

Adds new DynamicImageRenderer into the Plot.renderers

Parameters:image_source (ImageSource) – a image source instance which contain image configuration
Keyword Arguments:
 Additional keyword arguments are passed on as-is to the dynamic image renderer
Returns:DynamicImageRenderer
Return type:DynamicImageRenderer
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 configuring 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

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_tile(tile_source, **kw)

Adds new TileRenderer into the Plot.renderers

Parameters:tile_source (TileSource) – a tile source instance which contain tileset configuration
Keyword Arguments:
 Additional keyword arguments are passed on as-is to the tile renderer
Returns:TileRenderer
Return type:TileRenderer
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 Model subclass as the single parameter:

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

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: above:List(Instance(Renderer))

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

axis

Splattable list of Axis objects.

background_fill
background_fill_alpha

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

The fill alpha for the plot background style.

background_fill_color

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

The fill color for the plot background style.

below

property type: below:List(Instance(Renderer))

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

border_fill
border_fill_alpha

property type: border_fill_alpha:NumberSpec(String, Dict(String, Either(String, Instance(Transform), Float)), Float)

The fill alpha for the plot border style.

border_fill_color

property type: border_fill_color:ColorSpec(String, Dict(String, Either(String, Instance(Transform), Color)), Color)

The fill color for the plot border style.

extra_x_ranges

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

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

This is useful for adding additional axes.

extra_y_ranges

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

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

This is useful for adding additional axes.

grid

Splattable list of Grid objects.

h_symmetry

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

hidpi

property type: hidpi:Bool

Whether to use HiDPI mode when available.

left

property type: left:List(Instance(Renderer))

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

legend

Splattable list of Legend objects.

lod_factor

property type: lod_factor:Int

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

lod_interval

property type: lod_interval:Int

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

lod_threshold

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

min_border

property type: min_border:Int

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

min_border_bottom

property type: min_border_bottom: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: min_border_left: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: min_border_right: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: min_border_top: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: outline_line_alpha:NumberSpec(String, Dict(String, Either(String, Instance(Transform), Float)), Float)

The line alpha for the plot border outline.

outline_line_cap

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

The line cap for the plot border outline.

outline_line_color

property type: outline_line_color:ColorSpec(String, Dict(String, Either(String, Instance(Transform), Color)), Color)

The line color for the plot border outline.

outline_line_dash

property type: outline_line_dash:DashPattern

The line dash for the plot border outline.

outline_line_dash_offset

property type: outline_line_dash_offset:Int

The line dash offset for the plot border outline.

outline_line_join

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

The line join for the plot border outline.

outline_line_width

property type: outline_line_width:NumberSpec(String, Dict(String, Either(String, Instance(Transform), Float)), Float)

The line width for the plot border outline.

plot_height

property type: plot_height: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: plot_width: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: renderers: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
right

property type: right:List(Instance(Renderer))

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

title

property type: title:TitleProp(Instance(Title), String)

A title for the plot. Can be a text string or a Title annotation. Default is Title(text=””).

title_location

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

Where the title will be located. Titles on the left or right side will be rotated.

title_standoff
title_text_align
title_text_alpha
title_text_baseline
title_text_color
title_text_font
title_text_font_size
title_text_font_style
tool_events

property type: tool_events:Instance(ToolEvents)

A ToolEvents object to share and report tool events.

toolbar

property type: toolbar:Instance(Toolbar)

The toolbar associated with this plot which holds all the tools.

The toolbar is automatically created with the plot.

toolbar_location

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

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

toolbar_sticky

property type: toolbar_sticky:Bool

Stick the toolbar to the edge of the plot. Default: True. If False, the toolbar will be outside of the axes, titles etc.

tools
v_symmetry

property type: v_symmetry: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: webgl: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: x_mapper_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: x_range:Instance(Range)

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

xaxis

Splattable list of Axis objects for the x dimension.

xgrid

Splattable list of Grid objects for the x dimension.

y_mapper_type

property type: y_mapper_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: y_range:Instance(Range)

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

yaxis

Splattable list of Axis objects for the y dimension.

ygrid

Splattable list of Grid objects for the y dimension.

JSON Prototype
{
  "above": [],
  "background_fill_alpha": {
    "value": 1.0
  },
  "background_fill_color": {
    "value": "#ffffff"
  },
  "below": [],
  "border_fill_alpha": {
    "value": 1.0
  },
  "border_fill_color": {
    "value": "#ffffff"
  },
  "disabled": false,
  "extra_x_ranges": {},
  "extra_y_ranges": {},
  "h_symmetry": true,
  "height": null,
  "hidpi": true,
  "id": "4145233b-6031-49fc-9155-25b1e08b3573",
  "left": [],
  "lod_factor": 10,
  "lod_interval": 300,
  "lod_threshold": 2000,
  "lod_timeout": 500,
  "min_border": 5,
  "min_border_bottom": null,
  "min_border_left": null,
  "min_border_right": null,
  "min_border_top": null,
  "name": null,
  "outline_line_alpha": {
    "value": 1.0
  },
  "outline_line_cap": "butt",
  "outline_line_color": {
    "value": "#e5e5e5"
  },
  "outline_line_dash": [],
  "outline_line_dash_offset": 0,
  "outline_line_join": "miter",
  "outline_line_width": {
    "value": 1
  },
  "plot_height": 600,
  "plot_width": 600,
  "renderers": [],
  "right": [],
  "sizing_mode": "fixed",
  "tags": [],
  "title": {
    "id": "4106bddc-0057-4e93-b121-efc5be88ffd2",
    "type": "Title"
  },
  "title_location": "above",
  "tool_events": {
    "id": "f9d6e90f-72d8-4fab-b6fe-bd6dd835586c",
    "type": "ToolEvents"
  },
  "toolbar": {
    "id": "77215f7e-fabb-4908-8f69-e354c4514093",
    "type": "Toolbar"
  },
  "toolbar_location": "right",
  "toolbar_sticky": true,
  "v_symmetry": false,
  "webgl": false,
  "width": null,
  "x_mapper_type": "auto",
  "x_range": null,
  "y_mapper_type": "auto",
  "y_range": null
}
DEFAULT_TITLE()