POSTA (Presentation Of Sincere Total Adquisitions) plots provide kernel-density aware scatter plots with a seaborn-like API.
Each point is jittered horizontally according to the estimated density at its vertical position, so the cloud of points approximates the underlying distribution when a lot of observations are availabe, and functios as a regular strip or swarm plot with few points, making it a good default plot type.
python -m pip install "https://github.com/mwappner/postaplot/archive/refs/heads/main.zip"
Requires Python ≥3.8, and depends on numpy, scipy, matplotlib, pandas. PyPI coming soon.
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import postaplot
df = pd.DataFrame({
"group": np.repeat(["A","B","C"], 100),
"y": np.r_[np.random.normal(0,1,100),
np.random.normal(1,1,100),
np.random.standard_t(4,100)]
})
fig, ax = plt.subplots()
postaplot.kde_scatter(df, x="group", y="y", ax=ax, seed=0)
plt.show()- KDE-based jitter → point cloud approximates density.
- Discrete or continuous
hue- discrete → legend
- continuous → colorbar
- customizable order, mapping and normalization
- Dodge discrete subgroups into separate sub-clouds.
- Add boxplots with a simple toggle.
- Flexible marker styling:
- aliases:
ms,mfc,mec,mewwork like inplot(). hollow=Truefor edge-only markers.
- aliases:
- Clouds are rasterized if they have too many points (configurable)
- User-facing API:
kde_scatter - Low-level engine:
kde_scatter_engine(returnsPathCollection).
See the Cookbook for examples:
- Normal vs uniform jitter
- Jitter width control
- Discrete vs continuous hue and customization
- Hollow markers (edge-colored by hue)
- Dodging multiple groups
- Boxplots
- Colorbars and legends
- Custom edge vs face colors
MIT
