holoviews.plotting Package


plotting Package

HoloViews plotting sub-system the defines the interface to be used by any third-party plotting/rendering package.

This file defines the HTML tags used to wrap rendered output for display in the IPython Notebook (optional).

class holoviews.plotting.Cycle(cycle=None, **params)[source]

Bases: param.parameterized.Parameterized

A simple container class that specifies cyclic options. A typical example would be to cycle the curve colors in an Overlay composed of an arbitrary number of curves. The values may be supplied as an explicit list or a key to look up in the default cycles attribute.

key = param.String(default=’default_colors’)

The key in the default_cycles dictionary used to specify the color cycle if values is not supplied.

values = param.List(bounds=(0, None), default=[])

The values the cycle will iterate over.

class holoviews.plotting.Plot(renderer=None, root=None, **params)[source]

Bases: param.parameterized.Parameterized

Base class of all Plot classes in HoloViews, designed to be general enough to use any plotting package or backend.

cleanup()[source]

Cleans up references to the plot on the attached Stream subscribers.

initialize_plot(ranges=None)[source]

Initialize the matplotlib figure.

push()[source]

Pushes plot updates to the frontend.

refresh(**kwargs)[source]

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)[source]

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

update(key)[source]

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

class holoviews.plotting.Renderer(*args, **params)[source]

Bases: holoviews.core.io.Exporter

The job of a Renderer is to turn the plotting state held within Plot classes into concrete, visual output in the form of the PNG, SVG, MP4 or WebM formats (among others). Note that a Renderer is a type of Exporter and must therefore follow the Exporter interface.

The Renderer needs to be able to use the .state property of the appropriate Plot classes associated with that renderer in order to generate output. The process of ‘drawing’ is execute by the Plots and the Renderer turns the final plotting state into output.

key_fn = param.Callable()

Renderers do not support the saving of object key metadata

info_fn = param.Callable()

Renderers do not support the saving of object info metadata

center = param.Boolean(bounds=(0, 1), default=True)

Whether to center the plot

backend = param.String(default=’’)

The full, lowercase name of the rendering backend or third part plotting package used e.g ‘matplotlib’ or ‘cairo’.

dpi = param.Integer(inclusive_bounds=(True, True))

The render resolution in dpi (dots per inch)

fig = param.ObjectSelector(default=’auto’, objects=[‘auto’])

Output render format for static figures. If None, no figure rendering will occur.

fps = param.Number(default=20, inclusive_bounds=(True, True))

Rendered fps (frames per second) for animated formats.

holomap = param.ObjectSelector(default=’auto’, objects=[‘scrubber’, ‘widgets’, None, ‘auto’])

Output render multi-frame (typically animated) format. If None, no multi-frame rendering will occur.

mode = param.ObjectSelector(default=’default’, objects=[‘default’, ‘server’])

Whether to render the object in regular or server mode. In server mode a bokeh Document will be returned which can be served as a bokeh server app. By default renders all output is rendered to HTML.

size = param.Integer(default=100, inclusive_bounds=(True, True))

The rendered size as a percentage size

widget_location = param.ObjectSelector(objects=[‘left’, ‘bottom’, ‘right’, ‘top’, ‘top_left’, ‘top_right’, ‘bottom_left’, ‘bottom_right’, ‘left_top’, ‘left_bottom’, ‘right_top’, ‘right_bottom’])

The position of the widgets relative to the plot.

widget_mode = param.ObjectSelector(default=’embed’, objects=[‘embed’, ‘live’])

The widget mode determining whether frames are embedded or generated ‘live’ when interacting with the widget.

css = param.Dict(class_=<class ‘dict’>, default={})

Dictionary of CSS attributes and values to apply to HTML output.

post_render_hooks = param.Dict(class_=<class ‘dict’>, default={‘svg’: [], ‘png’: []})

Optional dictionary of hooks that are applied to the rendered data (according to the output format) before it is returned. Each hook is passed the rendered data and the object that is being rendered. These hooks allow post-processing of rendered data before output is saved to file or displayed.

app(show=False, new_window=False, websocket_origin=None, port=0)[source]

Creates a bokeh app from a HoloViews object or plot. By default simply attaches the plot to bokeh’s curdoc and returns the Document, if show option is supplied creates an Application instance and displays it either in a browser window or inline if notebook extension has been loaded. Using the new_window option the app may be displayed in a new browser tab once the notebook extension has been loaded. A websocket origin is required when launching from an existing tornado server (such as the notebook) and it is not on the default port (‘localhost:8888’).

comm_manager

alias of pyviz_comms.CommManager

components(obj, fmt=None, comm=True, **kwargs)[source]

Returns data and metadata dictionaries containing HTML and JS components to include render in app, notebook, or standalone document.

classmethod encode(entry)

Classmethod that applies conditional encoding based on mime-type. Given an entry as returned by __call__ return the data in the appropriate encoding.

export_widgets(filename, fmt=None, template=None, json=False, json_path='', **kwargs)[source]

Render and export object as a widget to a static HTML file. Allows supplying a custom template formatting string with fields to interpolate ‘js’, ‘css’ and the main ‘html’ containing the widget. Also provides options to export widget data to a json file in the supplied json_path (defaults to current path).

get_plot(doc=None, renderer=None, comm=None, **kwargs)[source]

Given a HoloViews Viewable return a corresponding plot instance.

get_plot_state(renderer=None, **kwargs)[source]

Given a HoloViews Viewable return a corresponding plot state.

get_size()[source]

Return the display size associated with a plot before rendering to any particular format. Used to generate appropriate HTML display.

Returns a tuple of (width, height) in pixels.

html(obj, fmt=None, css=None, resources='CDN', **kwargs)[source]

Renders plot or data structure and wraps the output in HTML. The comm argument defines whether the HTML output includes code to initialize a Comm, if the plot supplies one.

classmethod html_assets(core=True, extras=True, backends=None, script=False)[source]

Deprecated: No longer needed

instance()

Return an instance of this class, copying parameters from any existing instance provided.

classmethod load_nb(inline=True)[source]

Loads any resources required for display of plots in the Jupyter notebook

classmethod plot_options(obj, percent_size)[source]

Given an object and a percentage size (as supplied by the %output magic) return all the appropriate plot options that would be used to instantiate a plot class for that element.

Default plot sizes at the plotting class level should be taken into account.

classmethod plotting_class(obj)[source]

Given an object or Element class, return the suitable plotting class needed to render it with the current renderer.

pprint(imports=None, prefix='\n ', unknown_value='<?>', qualify=False, separator='')

Same as Parameterized.pprint, except that X.classname(Y is replaced with X.classname.instance(Y

save(basename, fmt='auto', key={}, info={}, options=None, resources='inline', title=None, **kwargs)[source]

Save a HoloViews object to file, either using an explicitly supplied format or to the appropriate default.

script_repr(imports=[], prefix=' ')

Same as Parameterized.script_repr, except that X.classname(Y is replaced with X.classname.instance(Y

server_doc(doc=None)[source]

Get a bokeh Document with the plot attached. May supply an existing doc, otherwise bokeh.io.curdoc() is used to attach the plot to the global document instance.

classmethod state()[source]

Context manager to handle global state for a backend, allowing Plot classes to temporarily override that state.

static_html(obj, fmt=None, template=None)[source]

Generates a static HTML with the rendered object in the supplied format. Allows supplying a template formatting string with fields to interpolate ‘js’, ‘css’ and the main ‘html’.

classmethod validate(options)[source]

Validate an options dictionary for the renderer.



mixins Module

Inheritance diagram of holoviews.plotting.mixins

plot Module

Inheritance diagram of holoviews.plotting.plot

Public API for all plots supported by HoloViews, regardless of plotting package or backend. Every plotting classes must be a subclass of this Plot baseclass.

class holoviews.plotting.plot.DimensionedPlot(keys=None, dimensions=None, layout_dimensions=None, uniform=True, subplot=False, adjoined=None, layout_num=0, style=None, subplots=None, dynamic=False, **params)[source]

Bases: holoviews.plotting.plot.Plot

DimensionedPlot implements a number of useful methods to compute dimension ranges and titles containing the dimension values.

fontsize = param.Parameter()

Specifies various font sizes of the displayed text. Finer control is available by supplying a dictionary where any unmentioned keys revert to the default sizes, e.g: {‘ticks’:20, ‘title’:15, ‘ylabel’:5, ‘xlabel’:5, ‘zlabel’:5, ‘legend’:8, ‘legend_title’:13} You can set the font size of ‘zlabel’, ‘ylabel’ and ‘xlabel’ together using the ‘labels’ key.

fontscale = param.Number(inclusive_bounds=(True, True))

Scales the size of all fonts.

show_title = param.Boolean(bounds=(0, 1), default=True)

Whether to display the plot title.

title = param.String(default=’{label} {group}n{dimensions}’)

The formatting string for the title of this plot, allows defining a label group separator and dimension labels.

title_format = param.String()

Alias for title.

normalize = param.Boolean(bounds=(0, 1), default=True)

Whether to compute ranges across all Elements at this level of plotting. Allows selecting normalization at different levels for nested data containers.

projection = param.Parameter()

Allows supplying a custom projection to transform the axis coordinates during display. Example projections include ‘3d’ and ‘polar’ projections supported by some backends. Depending on the backend custom, projection objects may be supplied.

cleanup()

Cleans up references to the plot on the attached Stream subscribers.

compute_ranges(obj, key, ranges)[source]

Given an object, a specific key, and the normalization options, this method will find the specified normalization options on the appropriate OptionTree, group the elements according to the selected normalization option (i.e. either per frame or over the whole animation) and finally compute the dimension ranges in each group. The new set of ranges is returned.

initialize_plot(ranges=None)

Initialize the matplotlib figure.

matches(spec)[source]

Matches a specification against the current Plot.

push()

Pushes plot updates to the frontend.

refresh(**kwargs)

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

traverse(fn=None, specs=None, full_breadth=True)[source]

Traverses any nested DimensionedPlot returning a list of all plots that match the specs. The specs should be supplied as a list of either Plot types or callables, which should return a boolean given the plot class.

update(key)[source]

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

class holoviews.plotting.plot.GenericAdjointLayoutPlot(renderer=None, root=None, **params)[source]

Bases: holoviews.plotting.plot.Plot

AdjointLayoutPlot allows placing up to three Views in a number of predefined and fixed layouts, which are defined by the layout_dict class attribute. This allows placing subviews next to a main plot in either a ‘top’ or ‘right’ position.

cleanup()

Cleans up references to the plot on the attached Stream subscribers.

initialize_plot(ranges=None)

Initialize the matplotlib figure.

push()

Pushes plot updates to the frontend.

refresh(**kwargs)

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

update(key)

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

class holoviews.plotting.plot.GenericCompositePlot(layout, keys=None, dimensions=None, **params)[source]

Bases: holoviews.plotting.plot.DimensionedPlot

Parameters inherited from:

holoviews.plotting.plot.DimensionedPlot: fontsize, fontscale, show_title, title, title_format, normalize, projection

cleanup()

Cleans up references to the plot on the attached Stream subscribers.

compute_ranges(obj, key, ranges)

Given an object, a specific key, and the normalization options, this method will find the specified normalization options on the appropriate OptionTree, group the elements according to the selected normalization option (i.e. either per frame or over the whole animation) and finally compute the dimension ranges in each group. The new set of ranges is returned.

initialize_plot(ranges=None)

Initialize the matplotlib figure.

matches(spec)

Matches a specification against the current Plot.

push()

Pushes plot updates to the frontend.

refresh(**kwargs)

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

traverse(fn=None, specs=None, full_breadth=True)

Traverses any nested DimensionedPlot returning a list of all plots that match the specs. The specs should be supplied as a list of either Plot types or callables, which should return a boolean given the plot class.

update(key)

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

class holoviews.plotting.plot.GenericElementPlot(element, keys=None, ranges=None, dimensions=None, batched=False, overlaid=0, cyclic_index=0, zorder=0, style=None, overlay_dims={}, stream_sources=[], streams=None, **params)[source]

Bases: holoviews.plotting.plot.DimensionedPlot

Plotting baseclass to render contents of an Element. Implements methods to get the correct frame given a HoloMap, axis labels and extents and titles.

Parameters inherited from:

holoviews.plotting.plot.DimensionedPlot: fontsize, fontscale, show_title, title, title_format, normalize, projection

apply_ranges = param.Boolean(bounds=(0, 1), default=True)

Whether to compute the plot bounds from the data itself.

apply_extents = param.Boolean(bounds=(0, 1), default=True)

Whether to apply extent overrides on the Elements

bgcolor = param.ClassSelector(class_=(<class ‘str’>, <class ‘tuple’>))

If set bgcolor overrides the background color of the axis.

default_span = param.ClassSelector(class_=(<class ‘int’>, <class ‘float’>, <class ‘tuple’>), default=2.0)

Defines the span of an axis if the axis range is zero, i.e. if the lower and upper end of an axis are equal or no range is defined at all. For example if there is a single datapoint at 0 a default_span of 2.0 will result in axis ranges spanning from -1 to 1.

hooks = param.HookList(bounds=(0, None), default=[])

Optional list of hooks called when finalizing a plot. The hook is passed the plot object and the displayed element, and other plotting handles can be accessed via plot.handles.

invert_axes = param.Boolean(bounds=(0, 1), default=False)

Whether to invert the x- and y-axis

invert_xaxis = param.Boolean(bounds=(0, 1), default=False)

Whether to invert the plot x-axis.

invert_yaxis = param.Boolean(bounds=(0, 1), default=False)

Whether to invert the plot y-axis.

finalize_hooks = param.HookList(bounds=(0, None), default=[])

Deprecated; use hooks options instead.

logx = param.Boolean(bounds=(0, 1), default=False)

Whether the x-axis of the plot will be a log axis.

logy = param.Boolean(bounds=(0, 1), default=False)

Whether the y-axis of the plot will be a log axis.

padding = param.ClassSelector(class_=(<class ‘int’>, <class ‘float’>, <class ‘tuple’>), default=0.1)

Fraction by which to increase auto-ranged extents to make datapoints more visible around borders. To compute padding, the axis whose screen size is largest is chosen, and the range of that axis is increased by the specified fraction along each axis. Other axes are then padded ensuring that the amount of screen space devoted to padding is equal for all axes. If specified as a tuple, the int or float values in the tuple will be used for padding in each axis, in order (x,y or x,y,z). For example, for padding=0.2 on a 800x800-pixel plot, an x-axis with the range [0,10] will be padded by 20% to be [-1,11], while a y-axis with a range [0,1000] will be padded to be [-100,1100], which should make the padding be approximately the same number of pixels. But if the same plot is changed to have a height of only 200, the y-range will then be [-400,1400] so that the y-axis padding will still match that of the x-axis. It is also possible to declare non-equal padding value for the lower and upper bound of an axis by supplying nested tuples, e.g. padding=(0.1, (0, 0.1)) will pad the x-axis lower and upper bound as well as the y-axis upper bound by a fraction of 0.1 while the y-axis lower bound is not padded at all.

show_legend = param.Boolean(bounds=(0, 1), default=True)

Whether to show legend for the plot.

show_grid = param.Boolean(bounds=(0, 1), default=False)

Whether to show a Cartesian grid on the plot.

xaxis = param.ObjectSelector(default=’bottom’, objects=[‘top’, ‘bottom’, ‘bare’, ‘top-bare’, ‘bottom-bare’, None, True, False])

Whether and where to display the xaxis. The “bare” options allow suppressing all axis labels, including ticks and xlabel. Valid options are ‘top’, ‘bottom’, ‘bare’, ‘top-bare’ and ‘bottom-bare’.

yaxis = param.ObjectSelector(default=’left’, objects=[‘left’, ‘right’, ‘bare’, ‘left-bare’, ‘right-bare’, None, True, False])

Whether and where to display the yaxis. The “bare” options allow suppressing all axis labels, including ticks and ylabel. Valid options are ‘left’, ‘right’, ‘bare’, ‘left-bare’ and ‘right-bare’.

xlabel = param.String()

An explicit override of the x-axis label, if set takes precedence over the dimension label.

ylabel = param.String()

An explicit override of the y-axis label, if set takes precedence over the dimension label.

xlim = param.Tuple(default=(nan, nan), length=2)

User-specified x-axis range limits for the plot, as a tuple (low,high). If specified, takes precedence over data and dimension ranges.

ylim = param.Tuple(default=(nan, nan), length=2)

User-specified x-axis range limits for the plot, as a tuple (low,high). If specified, takes precedence over data and dimension ranges.

zlim = param.Tuple(default=(nan, nan), length=2)

User-specified z-axis range limits for the plot, as a tuple (low,high). If specified, takes precedence over data and dimension ranges.

xrotation = param.Integer(bounds=(0, 360), inclusive_bounds=(True, True))

Rotation angle of the xticks.

yrotation = param.Integer(bounds=(0, 360), inclusive_bounds=(True, True))

Rotation angle of the yticks.

xticks = param.Parameter()

Ticks along x-axis specified as an integer, explicit list of tick locations, or bokeh Ticker object. If set to None default bokeh ticking behavior is applied.

yticks = param.Parameter()

Ticks along y-axis specified as an integer, explicit list of tick locations, or bokeh Ticker object. If set to None default bokeh ticking behavior is applied.

cleanup()

Cleans up references to the plot on the attached Stream subscribers.

compute_ranges(obj, key, ranges)

Given an object, a specific key, and the normalization options, this method will find the specified normalization options on the appropriate OptionTree, group the elements according to the selected normalization option (i.e. either per frame or over the whole animation) and finally compute the dimension ranges in each group. The new set of ranges is returned.

get_aspect(xspan, yspan)[source]

Should define the aspect ratio of the plot.

get_extents(element, ranges, range_type='combined', xdim=None, ydim=None, zdim=None)[source]

Gets the extents for the axes from the current Element. The globally computed ranges can optionally override the extents.

The extents are computed by combining the data ranges, extents and dimension ranges. Each of these can be obtained individually by setting the range_type to one of:

  • ‘data’: Just the data ranges

  • ‘extents’: Element.extents

  • ‘soft’: Dimension.soft_range values

  • ‘hard’: Dimension.range values

To obtain the combined range, which includes range padding the default may be used:

  • ‘combined’: All the range types combined and padding applied

This allows Overlay plots to obtain each range and combine them appropriately for all the objects in the overlay.

get_padding(obj, extents)[source]

Computes padding along the axes taking into account the plot aspect.

get_zorder(overlay, key, el)[source]

Computes the z-order of element in the NdOverlay taking into account possible batching of elements.

initialize_plot(ranges=None)

Initialize the matplotlib figure.

matches(spec)

Matches a specification against the current Plot.

push()

Pushes plot updates to the frontend.

refresh(**kwargs)

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

traverse(fn=None, specs=None, full_breadth=True)

Traverses any nested DimensionedPlot returning a list of all plots that match the specs. The specs should be supplied as a list of either Plot types or callables, which should return a boolean given the plot class.

update(key)

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

update_frame(key, ranges=None)[source]

Set the plot(s) to the given frame number. Operates by manipulating the matplotlib objects held in the self._handles dictionary.

If n is greater than the number of available frames, update using the last available frame.

class holoviews.plotting.plot.GenericLayoutPlot(layout, **params)[source]

Bases: holoviews.plotting.plot.GenericCompositePlot

A GenericLayoutPlot accepts either a Layout or a NdLayout and displays the elements in a cartesian grid in scanline order.

Parameters inherited from:

holoviews.plotting.plot.DimensionedPlot: fontsize, fontscale, show_title, title, title_format, normalize, projection

transpose = param.Boolean(bounds=(0, 1), default=False)

Whether to transpose the layout when plotting. Switches from row-based left-to-right and top-to-bottom scanline order to column-based top-to-bottom and left-to-right order.

cleanup()

Cleans up references to the plot on the attached Stream subscribers.

compute_ranges(obj, key, ranges)

Given an object, a specific key, and the normalization options, this method will find the specified normalization options on the appropriate OptionTree, group the elements according to the selected normalization option (i.e. either per frame or over the whole animation) and finally compute the dimension ranges in each group. The new set of ranges is returned.

initialize_plot(ranges=None)

Initialize the matplotlib figure.

matches(spec)

Matches a specification against the current Plot.

push()

Pushes plot updates to the frontend.

refresh(**kwargs)

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

traverse(fn=None, specs=None, full_breadth=True)

Traverses any nested DimensionedPlot returning a list of all plots that match the specs. The specs should be supplied as a list of either Plot types or callables, which should return a boolean given the plot class.

update(key)

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

class holoviews.plotting.plot.GenericOverlayPlot(overlay, ranges=None, batched=True, keys=None, group_counter=None, **params)[source]

Bases: holoviews.plotting.plot.GenericElementPlot

Plotting baseclass to render (Nd)Overlay objects. It implements methods to handle the creation of ElementPlots, coordinating style groupings and zorder for all layers across a HoloMap. It also allows collapsing of layers via the Compositor.

Parameters inherited from:

holoviews.plotting.plot.DimensionedPlot: fontsize, fontscale, show_title, title, title_format, normalize, projection

holoviews.plotting.plot.GenericElementPlot: apply_ranges, apply_extents, bgcolor, default_span, hooks, invert_axes, invert_xaxis, invert_yaxis, finalize_hooks, logx, logy, padding, show_grid, xaxis, yaxis, xlabel, ylabel, xlim, ylim, zlim, xrotation, yrotation, xticks, yticks

show_legend = param.Boolean(bounds=(0, 1), default=True)

Whether to show legend for the plot.

batched = param.Boolean(bounds=(0, 1), default=True)

Whether to plot Elements NdOverlay in a batched plotting call if possible. Disables legends and zorder may not be preserved.

legend_limit = param.Integer(default=25, inclusive_bounds=(True, True))

Number of rendered glyphs before legends are disabled.

style_grouping = param.Integer(default=2, inclusive_bounds=(True, True))

The length of the type.group.label spec that will be used to group Elements into style groups. A style_grouping value of 1 will group just by type, a value of 2 will group by type and group, and a value of 3 will group by the full specification.

cleanup()

Cleans up references to the plot on the attached Stream subscribers.

compute_ranges(obj, key, ranges)

Given an object, a specific key, and the normalization options, this method will find the specified normalization options on the appropriate OptionTree, group the elements according to the selected normalization option (i.e. either per frame or over the whole animation) and finally compute the dimension ranges in each group. The new set of ranges is returned.

get_aspect(xspan, yspan)

Should define the aspect ratio of the plot.

get_extents(overlay, ranges, range_type='combined')[source]

Gets the extents for the axes from the current Element. The globally computed ranges can optionally override the extents.

The extents are computed by combining the data ranges, extents and dimension ranges. Each of these can be obtained individually by setting the range_type to one of:

  • ‘data’: Just the data ranges

  • ‘extents’: Element.extents

  • ‘soft’: Dimension.soft_range values

  • ‘hard’: Dimension.range values

To obtain the combined range, which includes range padding the default may be used:

  • ‘combined’: All the range types combined and padding applied

This allows Overlay plots to obtain each range and combine them appropriately for all the objects in the overlay.

get_padding(obj, extents)

Computes padding along the axes taking into account the plot aspect.

get_zorder(overlay, key, el)

Computes the z-order of element in the NdOverlay taking into account possible batching of elements.

initialize_plot(ranges=None)

Initialize the matplotlib figure.

matches(spec)

Matches a specification against the current Plot.

push()

Pushes plot updates to the frontend.

refresh(**kwargs)

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

traverse(fn=None, specs=None, full_breadth=True)

Traverses any nested DimensionedPlot returning a list of all plots that match the specs. The specs should be supplied as a list of either Plot types or callables, which should return a boolean given the plot class.

update(key)

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

update_frame(key, ranges=None)

Set the plot(s) to the given frame number. Operates by manipulating the matplotlib objects held in the self._handles dictionary.

If n is greater than the number of available frames, update using the last available frame.

class holoviews.plotting.plot.Plot(renderer=None, root=None, **params)[source]

Bases: param.parameterized.Parameterized

Base class of all Plot classes in HoloViews, designed to be general enough to use any plotting package or backend.

cleanup()[source]

Cleans up references to the plot on the attached Stream subscribers.

initialize_plot(ranges=None)[source]

Initialize the matplotlib figure.

push()[source]

Pushes plot updates to the frontend.

refresh(**kwargs)[source]

Refreshes the plot by rerendering it and then pushing the updated data if the plot has an associated Comm.

set_root(root)[source]

Sets the root model on all subplots.

property state

The plotting state that gets updated via the update method and used by the renderer to generate output.

update(key)[source]

Update the internal state of the Plot to represent the given key tuple (where integers represent frames). Returns this state.

class holoviews.plotting.plot.PlotSelector(selector, plot_classes, allow_mismatch=False)[source]

Bases: object

Proxy that allows dynamic selection of a plotting class based on a function of the plotted object. Behaves like a Plot class and presents the same parameterized interface.


renderer Module

Inheritance diagram of holoviews.plotting.renderer

Public API for all plotting renderers supported by HoloViews, regardless of plotting package or backend.

class holoviews.plotting.renderer.Renderer(*args, **params)[source]

Bases: holoviews.core.io.Exporter

The job of a Renderer is to turn the plotting state held within Plot classes into concrete, visual output in the form of the PNG, SVG, MP4 or WebM formats (among others). Note that a Renderer is a type of Exporter and must therefore follow the Exporter interface.

The Renderer needs to be able to use the .state property of the appropriate Plot classes associated with that renderer in order to generate output. The process of ‘drawing’ is execute by the Plots and the Renderer turns the final plotting state into output.

key_fn = param.Callable()

Renderers do not support the saving of object key metadata

info_fn = param.Callable()

Renderers do not support the saving of object info metadata

center = param.Boolean(bounds=(0, 1), default=True)

Whether to center the plot

backend = param.String(default=’’)

The full, lowercase name of the rendering backend or third part plotting package used e.g ‘matplotlib’ or ‘cairo’.

dpi = param.Integer(inclusive_bounds=(True, True))

The render resolution in dpi (dots per inch)

fig = param.ObjectSelector(default=’auto’, objects=[‘auto’])

Output render format for static figures. If None, no figure rendering will occur.

fps = param.Number(default=20, inclusive_bounds=(True, True))

Rendered fps (frames per second) for animated formats.

holomap = param.ObjectSelector(default=’auto’, objects=[‘scrubber’, ‘widgets’, None, ‘auto’])

Output render multi-frame (typically animated) format. If None, no multi-frame rendering will occur.

mode = param.ObjectSelector(default=’default’, objects=[‘default’, ‘server’])

Whether to render the object in regular or server mode. In server mode a bokeh Document will be returned which can be served as a bokeh server app. By default renders all output is rendered to HTML.

size = param.Integer(default=100, inclusive_bounds=(True, True))

The rendered size as a percentage size

widget_location = param.ObjectSelector(objects=[‘left’, ‘bottom’, ‘right’, ‘top’, ‘top_left’, ‘top_right’, ‘bottom_left’, ‘bottom_right’, ‘left_top’, ‘left_bottom’, ‘right_top’, ‘right_bottom’])

The position of the widgets relative to the plot.

widget_mode = param.ObjectSelector(default=’embed’, objects=[‘embed’, ‘live’])

The widget mode determining whether frames are embedded or generated ‘live’ when interacting with the widget.

css = param.Dict(class_=<class ‘dict’>, default={})

Dictionary of CSS attributes and values to apply to HTML output.

post_render_hooks = param.Dict(class_=<class ‘dict’>, default={‘svg’: [], ‘png’: []})

Optional dictionary of hooks that are applied to the rendered data (according to the output format) before it is returned. Each hook is passed the rendered data and the object that is being rendered. These hooks allow post-processing of rendered data before output is saved to file or displayed.

app(show=False, new_window=False, websocket_origin=None, port=0)[source]

Creates a bokeh app from a HoloViews object or plot. By default simply attaches the plot to bokeh’s curdoc and returns the Document, if show option is supplied creates an Application instance and displays it either in a browser window or inline if notebook extension has been loaded. Using the new_window option the app may be displayed in a new browser tab once the notebook extension has been loaded. A websocket origin is required when launching from an existing tornado server (such as the notebook) and it is not on the default port (‘localhost:8888’).

comm_manager

alias of pyviz_comms.CommManager

components(obj, fmt=None, comm=True, **kwargs)[source]

Returns data and metadata dictionaries containing HTML and JS components to include render in app, notebook, or standalone document.

classmethod encode(entry)

Classmethod that applies conditional encoding based on mime-type. Given an entry as returned by __call__ return the data in the appropriate encoding.

export_widgets(filename, fmt=None, template=None, json=False, json_path='', **kwargs)[source]

Render and export object as a widget to a static HTML file. Allows supplying a custom template formatting string with fields to interpolate ‘js’, ‘css’ and the main ‘html’ containing the widget. Also provides options to export widget data to a json file in the supplied json_path (defaults to current path).

get_plot(doc=None, renderer=None, comm=None, **kwargs)[source]

Given a HoloViews Viewable return a corresponding plot instance.

get_plot_state(renderer=None, **kwargs)[source]

Given a HoloViews Viewable return a corresponding plot state.

get_size()[source]

Return the display size associated with a plot before rendering to any particular format. Used to generate appropriate HTML display.

Returns a tuple of (width, height) in pixels.

html(obj, fmt=None, css=None, resources='CDN', **kwargs)[source]

Renders plot or data structure and wraps the output in HTML. The comm argument defines whether the HTML output includes code to initialize a Comm, if the plot supplies one.

classmethod html_assets(core=True, extras=True, backends=None, script=False)[source]

Deprecated: No longer needed

instance()

Return an instance of this class, copying parameters from any existing instance provided.

classmethod load_nb(inline=True)[source]

Loads any resources required for display of plots in the Jupyter notebook

classmethod plot_options(obj, percent_size)[source]

Given an object and a percentage size (as supplied by the %output magic) return all the appropriate plot options that would be used to instantiate a plot class for that element.

Default plot sizes at the plotting class level should be taken into account.

classmethod plotting_class(obj)[source]

Given an object or Element class, return the suitable plotting class needed to render it with the current renderer.

pprint(imports=None, prefix='\n ', unknown_value='<?>', qualify=False, separator='')

Same as Parameterized.pprint, except that X.classname(Y is replaced with X.classname.instance(Y

save(basename, fmt='auto', key={}, info={}, options=None, resources='inline', title=None, **kwargs)[source]

Save a HoloViews object to file, either using an explicitly supplied format or to the appropriate default.

script_repr(imports=[], prefix=' ')

Same as Parameterized.script_repr, except that X.classname(Y is replaced with X.classname.instance(Y

server_doc(doc=None)[source]

Get a bokeh Document with the plot attached. May supply an existing doc, otherwise bokeh.io.curdoc() is used to attach the plot to the global document instance.

classmethod state()[source]

Context manager to handle global state for a backend, allowing Plot classes to temporarily override that state.

static_html(obj, fmt=None, template=None)[source]

Generates a static HTML with the rendered object in the supplied format. Allows supplying a template formatting string with fields to interpolate ‘js’, ‘css’ and the main ‘html’.

classmethod validate(options)[source]

Validate an options dictionary for the renderer.


util Module

Inheritance diagram of holoviews.plotting.util
class holoviews.plotting.util.CMapInfo(name, provider, category, source, bg)

Bases: tuple

property bg

Alias for field number 4

property category

Alias for field number 2

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

property name

Alias for field number 0

property provider

Alias for field number 1

property source

Alias for field number 3

class holoviews.plotting.util.Warning(*, fig, holomap, widgets, fps, max_frames, size, dpi, filename, info, css, widget_location)[source]

Bases: param.parameterized.Parameterized

holoviews.plotting.util.attach_streams(plot, obj, precedence=1.1)[source]

Attaches plot refresh to all streams on the object.

holoviews.plotting.util.color_intervals(colors, levels, clip=None, N=255)[source]

Maps the supplied colors into bins defined by the supplied levels. If a clip tuple is defined the bins are clipped to the defined range otherwise the range is computed from the levels and returned.

colors: list

List of colors (usually hex string or named colors)

levels: list or array_like

Levels specifying the bins to map the colors to

clip: tuple (optional)

Lower and upper limits of the color range

N: int

Number of discrete colors to map the range onto

cmap: list

List of colors

clip: tuple

Lower and upper bounds of the color range

holoviews.plotting.util.compute_overlayable_zorders(obj, path=[])[source]

Traverses an overlayable composite container to determine which objects are associated with specific (Nd)Overlay layers by z-order, making sure to take DynamicMap Callables into account. Returns a mapping between the zorders of each layer and a corresponding lists of objects.

Used to determine which overlaid subplots should be linked with Stream callbacks.

holoviews.plotting.util.compute_sizes(sizes, size_fn, scaling_factor, scaling_method, base_size)[source]

Scales point sizes according to a scaling factor, base size and size_fn, which will be applied before scaling.

holoviews.plotting.util.dim_axis_label(dimensions, separator=', ')[source]

Returns an axis label for one or more dimensions.

holoviews.plotting.util.dim_range_key(eldim)[source]

Returns the key to look up a dimension range.

holoviews.plotting.util.displayable(obj)[source]

Predicate that returns whether the object is displayable or not (i.e whether the object obeys the nesting hierarchy

holoviews.plotting.util.dynamic_update(plot, subplot, key, overlay, items)[source]

Given a plot, subplot and dynamically generated (Nd)Overlay find the closest matching Element for that plot.

holoviews.plotting.util.get_axis_padding(padding)[source]

Process a padding value supplied as a tuple or number and returns padding values for x-, y- and z-axis.

holoviews.plotting.util.get_directed_graph_paths(element, arrow_length)[source]

Computes paths for a directed path which include an arrow to indicate the directionality of each edge.

holoviews.plotting.util.get_dynamic_mode(composite)[source]

Returns the common mode of the dynamic maps in given composite object

holoviews.plotting.util.get_min_distance(element)[source]

Gets the minimum sampling distance of the x- and y-coordinates in a grid.

holoviews.plotting.util.get_minimum_span(low, high, span)[source]

If lower and high values are equal ensures they are separated by the defined span.

holoviews.plotting.util.get_nested_plot_frame(obj, key_map, cached=False)[source]

Extracts a single frame from a nested object.

Replaces any HoloMap or DynamicMap in the nested data structure, with the item corresponding to the supplied key.

Args:

obj: Nested Dimensioned object key_map: Dictionary mapping between dimensions and key value cached: Whether to allow looking up key in cache

Returns:

Nested datastructure where maps are replaced with single frames

holoviews.plotting.util.get_plot_frame(map_obj, key_map, cached=False)[source]

Returns the current frame in a mapping given a key mapping.

Args:

obj: Nested Dimensioned object key_map: Dictionary mapping between dimensions and key value cached: Whether to allow looking up key in cache

Returns:

The item in the mapping corresponding to the supplied key.

holoviews.plotting.util.get_range(element, ranges, dimension)[source]

Computes the data, soft- and hard-range along a dimension given an element and a dictionary of ranges.

holoviews.plotting.util.get_sideplot_ranges(plot, element, main, ranges)[source]

Utility to find the range for an adjoined plot given the plot, the element, the Element the plot is adjoined to and the dictionary of ranges.

holoviews.plotting.util.hex2rgb(hex)[source]

“#FFFFFF” -> [255,255,255]

holoviews.plotting.util.initialize_dynamic(obj)[source]

Initializes all DynamicMap objects contained by the object

holoviews.plotting.util.initialize_unbounded(obj, dimensions, key)[source]

Initializes any DynamicMaps in unbounded mode.

holoviews.plotting.util.is_dynamic_overlay(dmap)[source]

Traverses a DynamicMap graph and determines if any components were overlaid dynamically (i.e. by * on a DynamicMap).

holoviews.plotting.util.isoverlay_fn(obj)[source]

Determines whether object is a DynamicMap returning (Nd)Overlay types.

holoviews.plotting.util.linear_gradient(start_hex, finish_hex, n=10)[source]

Interpolates the color gradient between to hex colors

holoviews.plotting.util.list_cmaps(provider=None, records=False, name=None, category=None, source=None, bg=None, reverse=None)[source]

Return colormap names matching the specified filters.

holoviews.plotting.util.map_colors(arr, crange, cmap, hex=True)[source]

Maps an array of values to RGB hex strings, given a color range and colormap.

holoviews.plotting.util.mplcmap_to_palette(cmap, ncolors=None, categorical=False)[source]

Converts a matplotlib colormap to palette of RGB hex strings.”

holoviews.plotting.util.overlay_depth(obj)[source]

Computes the depth of a DynamicMap overlay if it can be determined otherwise return None.

holoviews.plotting.util.polylinear_gradient(colors, n)[source]

Interpolates the color gradients between a list of hex colors.

holoviews.plotting.util.process_cmap(cmap, ncolors=None, provider=None, categorical=False)[source]

Convert valid colormap specifications to a list of colors.

holoviews.plotting.util.register_cmaps(category, provider, source, bg, names)[source]

Maintain descriptions of colormaps that include the following information:

name - string name for the colormap category - intended use or purpose, mostly following matplotlib provider - package providing the colormap directly source - original source or creator of the colormaps bg - base/background color expected for the map

(‘light’,’dark’,’medium’,’any’ (unknown or N/A))

holoviews.plotting.util.resample_palette(palette, ncolors, categorical, cmap_categorical)[source]

Resample the number of colors in a palette to the selected number.

holoviews.plotting.util.rgb2hex(rgb)[source]

Convert RGB(A) tuple to hex.

holoviews.plotting.util.scale_fontsize(size, scaling)[source]

Scales a numeric or string font size.

holoviews.plotting.util.split_dmap_overlay(obj, depth=0)[source]

Splits a DynamicMap into the original component layers it was constructed from by traversing the graph to search for dynamically overlaid components (i.e. constructed by using * on a DynamicMap). Useful for assigning subplots of an OverlayPlot the streams that are responsible for driving their updates. Allows the OverlayPlot to determine if a stream update should redraw a particular subplot.

holoviews.plotting.util.traverse_setter(obj, attribute, value)[source]

Traverses the object and sets the supplied attribute on the object. Supports Dimensioned and DimensionedPlot types.

holoviews.plotting.util.undisplayable_info(obj, html=False)[source]

Generate helpful message regarding an undisplayable object

holoviews.plotting.util.within_range(range1, range2)[source]

Checks whether range1 is within the range specified by range2.