API#

Utilities#

help([kind, docstring, generic, style])

Print a docstring with all valid options which apply to the plot type.

hvplot_extension(*, compatibility, logo, name)

Helper utility used to load hvPlot/HoloViews extensions and control the notebook environment.

extension

alias of hvplot_extension

output(*args, **params)

Helper used to set HoloViews display options.

render(obj[, backend])

Renders the HoloViews object to the corresponding object in the specified backend, e.g. a Matplotlib or Bokeh figure.

save(obj, filename[, fmt, backend, ...])

Saves the supplied object to file.

show(obj[, title, port])

Starts a Bokeh server and displays the plot in a new tab.

Plotting#

hvPlot / .hvplot#

hvPlot’s plotting API is most often invoked by installing the hvplot namespace on a data source via a special import:

import pandas as pd
import hvplot.pandas  # noqa
df = pd.DataFrame()

df.hvplot.scatter()
# or
df.hvplot(kind='scatter')

Under the hood, these special imports like import hvplot.pandas register an accessor that returns an instance of an hvPlotBase class. Tabular-like data sources rely on the hvPlotTabular class and gridded-like sources on hvPlot (subclass of hvPlotTabular extended with methods like image):

  • hvPlotTabular: cuDF, Dask, Fugue, Ibis, Pandas, Streamz

  • hvPlotTabularDuckDB: DuckDB

  • hvPlotTabularPolars: Polars

  • hvPlot: Xarray

Instead of using the hvplot namespace, one can directly generate hvPlot plots with these classes:

import pandas as pd
from hvplot import hvPlot
df = pd.DataFrame()

hvPlot(df).scatter()
# or
hvPlot(df)(kind='scatter')

This section documents all the plotting methods of the hvPlot class, which as described above are also available via the hvplot namespace.

Common#

hvPlot.area([x, y, y2, stacked])

The area plot can be used to color the area under a line or to color the space between two lines.

hvPlot.bar([x, y, stacked])

A vertical bar plot

hvPlot.barh([x, y, stacked])

A horizontal bar plot

hvPlot.box([y, by])

The box plot gives you a visual idea about the locality, spread and skewness of numerical data through their quartiles.

hvPlot.bivariate([x, y, colorbar, ...])

A bivariate plot uses nested contours (or contours combined with color) to indicate regions of higher local density.

hvPlot.dataset([columns])

Wraps the dataset in a holoviews.element.Dataset object, for further processing with HoloViews.

hvPlot.density([y, by])

Alias of hvplot.hvPlot.kde().

hvPlot.errorbars([x, y, yerr1, yerr2])

errorbars provide a visual indicator for the variability of the plotted data on a graph.

hvPlot.heatmap([x, y, C, colorbar, logz])

heatmap visualises tabular data indexed by two key dimensions as a grid of colored values.

hvPlot.hexbin([x, y, C, colorbar, gridsize, ...])

The hexbin plot uses hexagons to split the area into several parts and attribute a color to it.

hvPlot.hist([y, by, bins, bin_range, ...])

A histogram displays an approximate representation of the distribution of continuous data.

hvPlot.kde([y, by])

The Kernel density estimate (kde) plot shows the distribution of the data.

hvPlot.labels([x, y, text])

Labels plot.

hvPlot.line([x, y])

The line plot connects the points with a continuous curve.

hvPlot.ohlc([x, y])

The ohlc plot visualizes the open, high, low and close prices of stocks and other assets.

hvPlot.paths([x, y, c])

Plot one or more collection of lines.

hvPlot.points([x, y])

A points plot visualizes positions in a 2D space.

hvPlot.polygons([x, y, c])

Polygon plot for geopandas dataframes.

hvPlot.scatter([x, y])

The scatter plot visualizes your points as markers in 2D space.

hvPlot.step([x, y, where])

The step plot connects the points with piece-wise constant curves.

hvPlot.table([columns])

Displays a 'table'.

hvPlot.vectorfield([x, y, angle, mag])

vectorfield visualizes vectors given by the (x, y) starting point, a magnitude (mag) and an angle.

hvPlot.violin([y, by])

violin plots are similar to box plots, but they provide a better sense of the distribution of data.

Gridded#

hvPlot.contour([x, y, z, colorbar, levels, logz])

Line contour plot.

hvPlot.contourf([x, y, z, colorbar, levels, ...])

Filled contour plot

hvPlot.image([x, y, z, colorbar])

Image plot

hvPlot.quadmesh([x, y, z, colorbar])

QuadMesh plot

hvPlot.rgb([x, y, z, bands])

RGB plot

plotting module#

hvPlot’s structure is based on Pandas’ plotting API and as such provides special plotting functions in the hvplot.plotting module.

andrews_curves(data, class_column[, ...])

Generate a plot of Andrews curves, for visualising clusters of multivariate data.

lag_plot(data[, lag])

Lag plot for time series.

parallel_coordinates(data, class_column[, ...])

Parallel coordinates plotting.

scatter_matrix(data[, c, chart, diagonal, ...])

Scatter matrix of numeric columns.

NetworkX#

The hvPlot NetworkX plotting API is meant as a drop-in replacement for the networkx.draw methods.

Note

Please chime in this issue if you have opinions about NetworkX plotting API in hvPlot.

draw(G[, pos])

Draw the graph G using hvPlot.

draw_networkx(G[, pos])

Draw a networkx graph.

draw_networkx_nodes(G, pos, **kwargs)

Draw networkx graph nodes.

draw_networkx_edges(G, pos, **kwargs)

Draw networkx graph edges.

draw_networkx_labels(G, pos, **kwargs)

Draw networkx graph node labels.

draw_circular(G, **kwargs)

Draw networkx graph with circular layout.

draw_kamada_kawai(G, **kwargs)

Draw networkx graph with circular layout.

draw_random(G, **kwargs)

Draw networkx graph with random layout.

draw_planar(G, **kwargs)

Draw networkx graph with planar layout.

draw_shell(G, **kwargs)

Draw networkx graph with shell layout.

draw_spectral(G, **kwargs)

Draw networkx graph with spectral layout.

draw_spring(G, **kwargs)

Draw networkx graph with spring layout.

Explorer#

The explorer interface can easily be created from the hvPlot / .hvplot namespace:

hvPlot.explorer([x, y])

The explorer plot allows you to interactively explore your data.

It is also available from the top-level explorer function:

explorer(data, **kwargs)

Explore your data and design your plot via an interactive user interface.

Calling the explorer function/method returns an hvPlotExplorer object:

hvPlotExplorer(df, **params)

hvPlotExplorer.hvplot()

Return the plot as a HoloViews object.

hvPlotExplorer.plot_code([var_name])

Return a string representation that can be easily copy-pasted in a notebook cell to create a plot from a call to the .hvplot accessor, and that includes all the customized settings of the explorer.

hvPlotExplorer.save(filename, **kwargs)

Save the plot to file.

hvPlotExplorer.servable([title, location, ...])

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

hvPlotExplorer.settings()

Return a dictionary of the customized settings.

hvPlotExplorer.show([title, port, address, ...])

Starts a Bokeh server and displays the Viewable in a new tab.

Sample Data#

The sampledata module provides convenient access to sample datasets from hvsampledata for learning and prototyping. While hvPlot itself does not require these datasets to function, installing hvsampledata allows you to easily reproduce the examples in the documentation, gallery and tutorials locally.

Installation#

If you installed hvPlot with minimal dependencies, you may need to install hvsampledata separately:

pip install hvsampledata
conda install conda-forge::hvsampledata

Usage#

import hvplot.pandas  # noqa
import hvplot.xarray  # noqa

penguins = hvplot.sampledata.penguins("pandas")
air_temp = hvplot.sampledata.air_temperature("xarray")
landsat = hvplot.sampledata.landsat_rgb("rioxarray")
us_states = hvplot.sampledata.us_states("geopandas")

Notes

  • All datasets include comprehensive metadata and documentation

  • Some datasets require additional dependencies e.g geopandas for Geographic datasets, xarray for Gridded datasets etc.

  • Data types and schemas are preserved across different engines where possible

See the GitHub Repository for more information.