holoviews.plotting.plot module#

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: Plot

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

Parameter Definitions


fontsize = Parameter(allow_None=True, label='Fontsize')

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 = Number(allow_None=True, inclusive_bounds=(True, True), label='Fontscale')

Scales the size of all fonts.

show_title = Boolean(default=True, label='Show title')

Whether to display the plot title.

title = String(default='{label} {group}\n{dimensions}', label='Title')

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

normalize = Boolean(default=True, label='Normalize')

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

projection = Parameter(allow_None=True, label='Projection')

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.

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.

matches(spec)[source]#

Matches a specification against the current Plot.

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

Parameter Definitions


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

Bases: DimensionedPlot

Parameter Definitions


Parameters inherited from:

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

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=None, stream_sources=None, streams=None, **params)[source]#

Bases: 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.

Parameter Definitions


Parameters inherited from:

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

apply_ranges = Boolean(default=True, label='Apply ranges')

Whether to compute the plot bounds from the data itself.

apply_extents = Boolean(default=True, label='Apply extents')

Whether to apply extent overrides on the Elements

bgcolor = ClassSelector(allow_None=True, class_=(<class 'str'>, <class 'tuple'>), label='Bgcolor')

If set bgcolor overrides the background color of the axis.

default_span = ClassSelector(class_=(<class 'int'>, <class 'float'>, <class 'tuple'>), default=2.0, label='Default span')

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 = HookList(bounds=(0, None), default=[], label='Hooks')

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 = Boolean(default=False, label='Invert axes')

Whether to invert the x- and y-axis

invert_xaxis = Boolean(default=False, label='Invert xaxis')

Whether to invert the plot x-axis.

invert_yaxis = Boolean(default=False, label='Invert yaxis')

Whether to invert the plot y-axis.

logx = Boolean(default=False, label='Logx')

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

logy = Boolean(default=False, label='Logy')

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

padding = ClassSelector(class_=(<class 'int'>, <class 'float'>, <class 'tuple'>), default=0.1, label='Padding')

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 = Boolean(default=True, label='Show legend')

Whether to show legend for the plot.

show_grid = Boolean(default=False, label='Show grid')

Whether to show a Cartesian grid on the plot.

xaxis = Selector(default='bottom', label='Xaxis', names={}, 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 = Selector(default='left', label='Yaxis', names={}, 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 = String(allow_None=True, label='Xlabel')

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

ylabel = String(allow_None=True, label='Ylabel')

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

xlim = Tuple(default=(nan, nan), label='Xlim', 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 = Tuple(default=(nan, nan), label='Ylim', length=2)

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

zlim = Tuple(default=(nan, nan), label='Zlim', 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 = Integer(allow_None=True, bounds=(0, 360), inclusive_bounds=(True, True), label='Xrotation')

Rotation angle of the xticks.

yrotation = Integer(allow_None=True, bounds=(0, 360), inclusive_bounds=(True, True), label='Yrotation')

Rotation angle of the yticks.

xticks = ClassSelector(allow_None=True, class_=(<class 'int'>, <class 'list'>, <class 'tuple'>, <class 'numpy.ndarray'>), label='Xticks')

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

yticks = ClassSelector(allow_None=True, class_=(<class 'int'>, <class 'list'>, <class 'tuple'>, <class 'numpy.ndarray'>), label='Yticks')

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

get_aspect(xspan, yspan)[source]#

Should define the aspect ratio of the plot.

get_extents(element, ranges, range_type='combined', dimension=None, xdim=None, ydim=None, zdim=None, lims_as_soft_ranges=False, **kwargs)[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.

If lims_as_soft_ranges is set to True, the xlim and ylim will be treated as soft ranges instead of the default case as hard ranges while computing the extents. This is used e.g. when apply_hard_bounds is True and xlim/ylim is set, in which case we limit the initial viewable range to xlim/ylim, but allow navigation up to the abs max between the data range and xlim/ylim.

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.

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: GenericCompositePlot

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

Parameter Definitions


Parameters inherited from:

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

transpose = Boolean(default=False, label='Transpose')

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.

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

Bases: 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.

Parameter Definitions


Parameters inherited from:

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

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

show_legend = Boolean(default=True, label='Show legend')

Whether to show legend for the plot.

batched = Boolean(default=True, label='Batched')

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

legend_limit = Integer(default=25, inclusive_bounds=(True, True), label='Legend limit')

Number of rendered glyphs before legends are disabled.

style_grouping = Integer(default=2, inclusive_bounds=(True, True), label='Style grouping')

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.

get_extents(overlay, ranges, range_type='combined', dimension=None, **kwargs)[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.

If lims_as_soft_ranges is set to True, the xlim and ylim will be treated as soft ranges instead of the default case as hard ranges while computing the extents. This is used e.g. when apply_hard_bounds is True and xlim/ylim is set, in which case we limit the initial viewable range to xlim/ylim, but allow navigation up to the abs max between the data range and xlim/ylim.

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

Bases: Parameterized

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

Parameter Definitions


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.