skills/hvplot/SKILL.md
Best practices for doing quick exploratory data analysis with minimal code and a Pandas .plot like API using HoloViews hvPlot.
npx skillsauth add marcskovmadsen/holoviz-mcp hvplotInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This document provides best practices for developing plots and charts with HoloViz hvPlot in notebooks and .py files.
Please develop as an Expert Python Developer developing advanced data-driven, analytics and testable data visualisations, dashboards and applications would do. Keep the code short, concise, documented, testable and professional.
Core dependencies provided with the hvplot Python package:
Optional dependencies from the HoloViz Ecosystem:
pip install hvplot hvsampledata panel watchfiles
For development in .py files DO always include watchfiles for Panel hotreload.
In the example below we will use the earthquakes sample data:
import hvsampledata
hvsampledata.earthquakes("pandas")
Tabular record of earthquake events from the USGS Earthquake Catalog that provides detailed
information including parameters such as time, location as latitude/longitude coordinates
and place name, depth, and magnitude. The dataset contains 596 events.
Note: The columns `depth_class` and `mag_class` were created by categorizing numerical values from
the `depth` and `mag` columns in the original dataset using custom-defined binning:
Depth Classification
| depth | depth_class |
|-----------|--------------|
| Below 70 | Shallow |
| 70 - 300 | Intermediate |
| Above 300 | Deep |
Magnitude Classification
| mag | mag_class |
|-------------|-----------|
| 3.9 - <4.9 | Light |
| 4.9 - <5.9 | Moderate |
| 5.9 - <6.9 | Strong |
| 6.9 - <7.9 | Major |
Schema
------
| name | type | description |
|:------------|:-----------|:--------------------------------------------------------------------|
| time | datetime | UTC Time when the event occurred. |
| lat | float | Decimal degrees latitude. Negative values for southern latitudes. |
| lon | float | Decimal degrees longitude. Negative values for western longitudes |
| depth | float | Depth of the event in kilometers. |
| depth_class | category | The depth category derived from the depth column. |
| mag | float | The magnitude for the event. |
| mag_class | category | The magnitude category derived from the mag column. |
| place | string | Textual description of named geographic region near to the event. |
Below is a simple reference example for data exploration.
import hvsampledata
# DO import panel if working in .py files
import panel as pn
# Do importing hvplot.pandas to add .hvplot namespace to Pandas DataFrames and Series
import hvplot.pandas # noqa: F401
# DO always run pn.extension() to load panel javascript extensions
pn.extension()
# Do keep the extraction, transformation and plotting of data clearly separate
# Extract: earthquakes sample data
data = hvsampledata.earthquakes("pandas")
# Transform: Group by mag_class and count occurrences
mag_class_counts = data.groupby('mag_class').size().reset_index(name='counts')
# Plot: counts by mag_class
plot = mag_class_counts.hvplot.bar(x='mag_class', y='counts', title='Earthquake Counts by Magnitude Class')
# If working in notebook DO output to plot:
plot
# Else if working in .py file DO:
# DO provide a method to serve the app with `panel serve`
if pn.state.served:
# DO remember to add .servable to the panel components you want to serve with the app
pn.panel(plot, sizing_mode="stretch_both").servable()
# DON'T provide a `if __name__ == "__main__":` method to serve the app with `python`
If working in a .py file DO always serve the plot with hotreload for manual testing while developing:
panel serve path/to/file.py --dev --show
DONT serve with python path_to_this_file.py.
import hvplot.pandas # will add .hvplot namespace to Pandas dataframes
import hvplot.polars # will add .hvplot namespace to Polars dataframes
...
from bokeh.models.formatters import NumeralTickFormatter
df.hvplot(
...,
yformatter=NumeralTickFormatter(format='0.00a'), # Format as 1.00M, 2.50M, etc.
)
| Input | Format String | Output | | - | - | - | | 1230974 | '0.0a' | 1.2m | | 1460 | '0 a' | 1 k | | -104000 | '0a' | -104k |
When developing a hvplot please serve it for development using Panel:
import pandas as pd
import hvplot.pandas # noqa
import panel as pn
import numpy as np
np.random.seed(42)
dates = pd.date_range("2022-08-01", periods=30, freq="B")
open_prices = np.cumsum(np.random.normal(100, 2, size=len(dates)))
high_prices = open_prices + np.random.uniform(1, 5, size=len(dates))
low_prices = open_prices - np.random.uniform(1, 5, size=len(dates))
close_prices = open_prices + np.random.uniform(-3, 3, size=len(dates))
data = pd.DataFrame({
"open": open_prices.round(2),
"high": high_prices.round(2),
"low": low_prices.round(2),
"close": close_prices.round(2),
}, index=dates)
# Create a scatter plot of date vs close price
scatter_plot = data.hvplot.scatter(x="index", y="close", grid=True, title="Close Price Scatter Plot", xlabel="Date", ylabel="Close Price")
# Create a Panel app
app = pn.Column("# Close Price Scatter Plot", scatter_plot)
if pn.state.served:
app.servable()
panel serve plot.py --dev
line - Line plots for time series and continuous data scatter - Scatter plots for exploring relationships between variables bar - Bar charts for categorical comparisons hist - Histograms for distribution analysis area - Area plots for stacked or filled visualizations
search (documentation), hvplot_list (available plot types), hvplot_get (docstrings and signatures), skill_get (best-practice skills).holoviz-mcp CLI is installed (also available as hv), use the equivalent CLI commands: holoviz-mcp search, holoviz-mcp hvplot list, holoviz-mcp hvplot get.streaming related information via https://hvplot.holoviz.org/en/docs/latest/search.html?q=streaming url.DO add tests to the tests folder and run them with pytest tests/path/to/test_file.py.
DO always start and keep running a development server panel serve path_to_file.py --dev --show with hot reload while developing!
--show flag, a browser tab will automatically open showing your app.--dev flag, the panel server and app will automatically reload if you change the code.--port {port-number} flag.--autoreload flagpython path_to_file.py to test or serve the app.pn.Column, pn.Tabs, pn.Accordion to layout multiple plotsdevelopment
Use when building Python classes with validated, typed parameters using the Param library. Triggers include creating configuration classes, building reusable components with state, implementing reactive dependencies between parameters, adding type-safe attributes with bounds/constraints, creating testable parameterized classes, or when users mention param.Parameterized, @param.depends, or param.watch.
tools
Best practices for developing tools, dashboards and interactive data apps with HoloViz Panel. Create reactive, component-based UIs with widgets, layouts, templates, and real-time updates. Use when developing interactive data exploration tools, dashboards, data apps, or any interactive Python web application. Supports file uploads, streaming data, multi-page apps, and integration with HoloViews, hvPlot, Pandas, Polars, DuckDB and the rest of the HoloViz and PyData ecosystems.
tools
Best practices for developing modern looking tools, dashboards and data apps using HoloViz Panel and Panel Material UI components.
data-ai
Best practices for integrating HoloViews and hvPlot visualizations into Panel applications. Use when embedding HoloViews/hvPlot plots in Panel panes, preserving zoom/pan state across data refreshes with DynamicMap, composing DynamicMap overlays without type errors, using HoloViews streams (Selection1D, RangeXY, Tap, BoundsXY, Pipe, Buffer) with Panel, cross-filtering with link_selections, making HoloViews plots responsive in Panel layouts, or wiring Panel widgets to Bokeh plot properties with jslink.