import hvplot.pandas # noqa
= hvplot.sampledata.synthetic_clusters("pandas")
df
df.hvplot.points(="x", y="y", rasterize=True, data_aspect=1,
x="log", selector="first",
cnorm )
Plotting made easy with hvPlot: 0.12 release
What is hvPlot?
hvPlot is an open-source library that offers powerful high-level functionality for data exploration and visualization without requiring you to learn a new API. You can create powerful interactive and compositional Bokeh, Matplotlib, or Plotly plots by simply replacing .plot
with .hvplot
. hvPlot makes all the analytical power of the HoloViz ecosystem available, using the APIs you already know.
New release!
We are very pleased to announce the 0.12 release of hvPlot! This release includes:
- 📚 Major expansion and improvement of the reference documentation, covering all plotting options and methods
- 🔢 Ability to switch between multiple versions of hvPlot on the website
- 🔍 A new
selector
option for sample hover info on datashaded plots - 🧰 Toolbar customization with
toolbar
andautohide_toolbar
- 📊 Flexible legends with the new
legend_cols
andlegend_opts
options - 🖌️ Advanced styling enabled by the
backend_opts
option - 📦 A new
sampledata
module for easy access to sample datasets
As always, the full changelog is available on GitHub.
Many thanks to @ahuang11, @hoxbro, @Azaya89, and @maximlt for their contributions!
You can install hvPlot with pip install hvplot
, or with conda install hvplot
(or conda install conda-forge::hvplot
) if you are using Anaconda.
🌟 An easy way to support hvPlot is to give it a star on GitHub! 🌟
Major expansion and improvement of the reference documentation
We were fortunate to receive a NumFocus Small Development Grant (SDG) to improve hvPlot’s documentation. Isaiah has been working hard since the beginning of the year to enhance the documentation. Some improvements were already released in the previous 0.11.x versions:
- Enhanced getting started tutorial
- Getting started tutorial for Pandas users
- API compatibility reference between hvPlot and Pandas
- Addition (finally!) of an API reference
In recent months, we focused on documenting:
- All plotting options. The Plotting Options page lists all options in tables grouped by category, with their name, accepted types, default value, and docstring. Each category links to detailed sub-pages with example usage and code snippets you can easily copy/paste into your scripts or notebooks.
- All plotting methods and functions. The API reference page links to specific plotting methods (e.g.,
scatter
), showing their docstring and an Examples section with small examples demonstrating usage and effects (e.g., themarker
option forscatter
). This page also lists all plotting backend styling options.
Ability to switch between multiple versions of hvPlot on the website
Thanks to the NumFocus SDG, we were able to (finally!!) add a version switcher to hvPlot’s website. In the HoloViz ecosystem, we often have special needs for documenting our libraries (long-running notebooks, large datasets, Pyodide integration, etc.), so we opted to host the site on AWS (S3 plus CloudFront). Some challenges included ensuring we didn’t break too many links during the transition (we customized a Lambda Edge function for that) and minimizing SEO impact (we added a canonical URL to Sphinx’s config file and ensured we served robots.txt
and sitemap.xml
files).
Use of the selector
option for rasterized hover info
The Datashader integration in hvPlot and HoloViews allows users to display and explore very large datasets (millions or billions of points!) in a browser. Over the years (see Jean-Luc’s talk), this integration has improved significantly, enhancing the user experience in HoloViz libraries (Datashader, HoloViews, hvPlot) and Bokeh. One key improvement is the ability to interact with datashaded plots and access underlying data.
For example, we now recommend setting rasterized=True
instead of datashader=True
. The latter renders data server-side as an RGB image, giving no access to the underlying dataset. In contrast, rasterized=True
sends aggregated data to the front-end, enabling colormapping and hover access to aggregated data. While rasterized=True
is great, it only exposes the aggregated data, i.e. the output of the reduction function Datashader runs to compute, for each pixel, an aggregated value (by default the count of points in that pixel). Wouldn’t it be great to inspect a specific pixel and see a sample of the data it contains?
This is where the selector
option comes in. It uses a specific kind of Datashader reduction called selector reduction to extract a selected row (and in the future, a set of N rows) for display in the hover tooltip. Currently, available reductions include first and last (samples based on data order in the pixel, mostly equivalent to a random sample) and min and max (row where the value of a specific variable is minimum or maximum, respectively).
Note that the selector
feature requires a live Python process, as hover tooltip data is sent live from the server. In the video below, you will see values for s
, val
, and cat
in the tooltip, all originating from the same row in the DataFrame.
Visit the selector
reference section and the Interactive Hover for Big Data HoloViews guide for more information. Future improvements are planned to enhance the user experience of this feature. We have started a discussion with the Bokeh maintainers to streamline hover behavior for small and large datashaded datasets.
Toolbar customization with toolbar
and autohide_toolbar
HoloViews 1.21 introduced the autohide_toolbar
plot option for the Bokeh backend, a long-requested feature that automatically hides the toolbar when the plot is not hovered (similar to Plotly’s default behavior). We also exposed the toolbar
option, which controls whether to display a toolbar and its location around the plot. Hover over the plot below to display the toolbar located above the plot.
import hvplot.polars # noqa
= hvplot.sampledata.penguins("polars")
df
df.hvplot.scatter("bill_depth_mm", "bill_length_mm", c="species",
="above", autohide_toolbar=True,
toolbar )
Visit the reference page on interactivity options to learn more about these two new options.
Flexible legends with the new legend_cols
and legend_opts
options
Plots colored by category often result in legends that require customization to display properly. With legend_cols
(to set the number of columns in the legend grid), legend_opts
(for advanced customization and styling), and the already available legend
option (to set the legend location), hvPlot users now have a comprehensive set of legend options to accommodate most use cases.
import hvplot.pandas # noqa
import numpy as np
import pandas as pd
= pd.DataFrame({"y": np.random.random(20), "cat": list(map(chr, range(97, 117)))})
df
df.hvplot.scatter(="cat", legend="left",legend_cols=3,
by={"background_fill_alpha": 0.2, "background_fill_color": "grey"}
legend_opts )
Visit the reference page on legend options to learn more about these new options.
Advanced styling enabled by the backend_opts
option
The backend_opts
option provides an advanced escape hatch for styling plots beyond their legend. It accepts a dictionary of accessor strings that mirror attribute access on the underlying plot object (e.g., Bokeh figure
, Matplotlib Figure
) and other subcomponents HoloViews keeps a handle on (legend, colorbar, etc.). Using this feature requires some knowledge of the active plotting backend (Bokeh, Matplotlib), but it is very likely LLMs can assist in defining this dictionary based on your styling needs.
import hvplot.xarray # noqa
= hvplot.sampledata.air_temperature("xarray").isel(time=slice(0, 5))
ds
ds.hvplot.image(="lon", y="lat", alpha=0.5, dynamic=False, framewise=False, widget_location="bottom",
x={
backend_opts"plot.xgrid.grid_line_color": "grey",
"plot.xgrid.grid_line_dash": "dashed",
"plot.xaxis.axis_label_text_font_style": "bold",
"plot.yaxis.axis_label_text_font_style": "bold",
"hover.attachment": "vertical",
} )
Visit the backend_opts
reference section for more information.
A new sampledata
module for easy access to sample datasets
We had been discussing for a while the creation of a package dedicated to sharing sample datasets. Most plotting libraries have their own sample datasets for documentation and examples. We have leveraged these extensively, particularly Bokeh’s sampledata
module. However, we also used datasets from various sources, complicating life for contributors (“Which dataset should I use?”) and users (“What library do I need to install to reproduce this example?”).
To streamline dataset handling, and as part of the NumFocus SDG work, we created the new experimental hvsampledata package. This package already includes lightweight datasets like the well-known Penguins dataset. The API to load a dataset is a function call hvsampledata.<dataset_name>(<data_library>, <optional_kwargs>)
, e.g., df = hvsampledata.penguins("pandas")
for a Pandas DataFrame or df = hvsampledata.penguins("polars", lazy=True)
for a Polars LazyFrame. This API aligns with HoloViz projects like hvPlot, HoloViews, and Panel, which work well with various data libraries.
To avoid importing hvsampledata
in every code snippet of hvPlot’s documentation, we added a new sampledata
module as a simple interface to hvsampledata
.
import hvplot.pandas # noqa
= hvplot.sampledata.us_states("geopandas")
gdf
=True, c="pop_density", cnorm="log") gdf.hvplot.polygons(geo
Future Documentation Work
We will continue improving the documentation. Our next major tasks include creating a new gallery with simple and advanced examples (similar to galleries in other plotting libraries) and restructuring user guides into Tutorials, How-To guides, and Explanation pages, following the Diataxis documentation framework.
Join us on GitHub, Discourse, or Discord to help us improve hvPlot. Happy plotting 😊