Skip to content

zen-laboratory/postaplot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI License: MIT

postaplot

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.

Installation

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.

Quickstart

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()

Features

  • 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, mew work like in plot().
    • hollow=True for edge-only markers.
  • Clouds are rasterized if they have too many points (configurable)
  • User-facing API: kde_scatter
  • Low-level engine: kde_scatter_engine (returns PathCollection).

Documentation

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

License

MIT

About

Kernel-density based scatter plots with seaborn-like API.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%