The PyData ecosystem has a number of core Python data containers that allow users to work with a wide array of datatypes, including:

  • Pandas: DataFrame, Series (columnar/tabular data)

  • Rapids cuDF: GPU DataFrame, Series (columnar/tabular data)

  • Dask: DataFrame, Series (distributed/out of core arrays and columnar data)

  • XArray: Dataset, DataArray (labelled multidimensional arrays)

  • Streamz: DataFrame(s), Series(s) (streaming columnar data)

  • Intake: DataSource (data catalogues)

  • GeoPandas: GeoDataFrame (geometry data)

  • NetworkX: Graph (network graphs)

Several of these libraries have the concept of a high-level plotting API that lets a user generate common plot types very easily. The native plotting APIs are generally built on Matplotlib, which provides a solid foundation, but it means that users miss out on the benefits of modern, interactive plotting libraries built for the web like Bokeh and HoloViews.

hvPlot provides a high-level plotting API built on HoloViews that provides a general and consistent API for plotting data in all the abovementioned formats. hvPlot can integrate neatly with the individual libraries if an extension mechanism for the native plot APIs is offered, or it can be used as a standalone component.

Basic usage#

hvPlot provides an alternative for the static plotting API provided by Pandas and other libraries, with by default an interactive Bokeh-based plotting API that supports panning, zooming, hovering, and clickable/selectable legends. Let’s first create some data.

import pandas as pd, numpy as np
idx = pd.date_range('1/1/2000', periods=1000)
df  = pd.DataFrame(np.random.randn(1000, 4), index=idx, columns=list('ABCD')).cumsum()

We need to import hvplot.pandas, this import has two side effects:

  • It makes the .hvplot accessor available on Pandas DataFrame and Series objects, which means that after that df.hvplot becomes a valid statement while before that it would raise an AttributeError.

  • It sets the Bokeh plotting library as the default one and loads the corresponding extension. In practice in a notebook it means that there’s actually some front-end code that is injected in the cell output of this import, this code is required for HoloViews plots to behave correctly so make sure not to remove this cell.

import hvplot.pandas  # noqa