holoviz / holoviz/hvplot

Add API to create ridge / joy plots?

Open
#1,342 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

The `subcoordinate_y` feature added to HoloViews opens the door to the implementation of [ridge / joy plots](https://en.wikipedia.org/wiki/Ridgeline_plot) in hvPlot. I'm opening this issue to gauge the interest in this feature and discuss it.

HoloViews code (stolen from Demetris'!)

```python
import numpy as np
import holoviews as hv
from scipy.stats import gaussian_kde

hv.extension('bokeh')

categories = ['A', 'B', 'C', 'D', 'E']
data = {cat: np.random.normal(loc=i-2, scale=1.0, size=100) for i, cat in enumerate(categories)}
x = np.linspace(-5, 5, 100)

curves = []
areas = []
for i, (cat, values) in enumerate(data.items()):
pdf = gaussian_kde(values)(x)
area = hv.Area((x, pdf), label=cat).opts(
subcoordinate_y=True,
subcoordinate_scale=1.5,
)
areas.append(area)

ridge_plot_areas = hv.Overlay(areas).opts(
width=900,
height=400,
)

ridge_plot_areas.opts(show_legend=False)
```


image

Python users can already create such plots using the usual plotting libraries, albeit usually by having to resort to low-level APIs:

- https://python-graph-gallery.com/ridgeline/
- Bokeh: https://docs.bokeh.org/en/latest/docs/examples/plotting/ridgeplot_subcoordinates.html
- Seaborn: https://seaborn.pydata.org/examples/kde_ridgeplot.html
- Plotly: https://plotly.com/python/violin/, https://github.com/plotly/plotly_express/issues/25
- Matplotlib: https://matplotlib.org/matplotblog/posts/create-ridgeplots-in-matplotlib/

I also found two packages implementing high-level APIs:

- ridgeplot (7K downloads/month): https://github.com/tpvasconcelos/ridgeplot
- joypy (15K downloads/month): https://github.com/leotac/joypy

And a few other packages from other ecosystems:

- ggridges: https://github.com/wilkelab/ggridges
- stata-joyplot: https://github.com/asjadnaqvi/stata-joyplot

(https://github.com/holoviz/hvplot/issues/1160 should be implemented first)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.