hvplot
hvplot is a high-level plotting API for the PyData ecosystem built on HoloViews. It provides a familiar API, similar to Pandas' `.plot()` method, to generate interactive and compositional plots from various data structures like Pandas DataFrames, Xarray DataArrays, Dask, GeoPandas, and Polars. It supports Bokeh (default), Matplotlib, and Plotly backends and is actively developed with frequent patch releases and minor versions.
Warnings
- deprecated The `hover_formatters` argument is deprecated in favor of `hover_tooltips`. Additionally, passing `DuckDB` objects directly to `hvplot.plotting.plot` is discouraged; users should instead `import hvplot.duckdb` to enable proper integration.
- gotcha hvplot outputs, especially with Bokeh or Plotly backends, may not display immediately or at all in some IDEs (like PyCharm) or Jupyter environments (requiring a page refresh) due to their limited notebook integration or specific HoloViews/Bokeh version incompatibilities.
- gotcha Some advanced plotting options, such as `subplots=True` for `hist` or `hexbin` plots, may have limited or no support with the Matplotlib backend. When plotting Dask DataFrames with Matplotlib, explicit computation (`.compute()`) might be necessary to avoid errors or blank plots.
- breaking For geographic plots with `tiles=True`, `hvplot>=0.11.0` automatically converts latitude/longitude to Web Mercator. Prior to `v0.11.0`, manual projection using utilities like `holoviews.util.transform.lon_lat_to_easting_northing` was often required.
- gotcha Line plots of time series or sparse data with `NaN` values may exhibit 'disappearing lines' when zooming in, especially if single data points are surrounded by `NaN`s, as a line requires at least two points. This can sometimes be exacerbated by WebGL rendering in older Bokeh versions.
Install
-
pip install hvplot -
conda install conda-forge::hvplot
Imports
- .hvplot accessor
import hvplot.pandas # or hvplot.xarray, hvplot.dask, etc.
- hvplot.extension
import hvplot.pandas hvplot.extension('matplotlib') - hvplot.show
from hvplot import show # ... create plot ... show(plot_object)
Quickstart
import pandas as pd
import numpy as np
import hvplot.pandas # noqa
df = pd.DataFrame(
np.random.randn(100, 4),
index=pd.date_range('1/1/2000', periods=100),
columns=list('ABCD')
).cumsum()
df.hvplot.line(y='A', title='Interactive Line Plot of Column A')