Make Simple Sankey Diagrams with Matplotlib and Seaborn
Project description
matSankey
A lightweight Python package for creating Sankey diagrams using matplotlib, flowing left to right.
matSankey is designed to integrate naturally into your existing matplotlib figures — just pass an ax argument and the diagram renders as a subplot alongside your other plots. Note that matSankey supports one-level flows only (A → B). Multi-level flows (A → B → C) are not yet supported.
Installation
From PyPI:
pip install matSankey
From source:
git clone https://github.com/LissHall/matSankey.git
cd matSankey
pip install .
Dependencies:
pip install matplotlib seaborn numpy
Quick Start
import matplotlib.pyplot as plt
from matsankey.sankey import sankey
left = ['A', 'A', 'B', 'B']
right = ['X', 'Y', 'X', 'Y']
weight = [100, 50, 30, 120]
fig, ax = plt.subplots(figsize=(8, 5))
sankey(left=left, right=right, leftWeight=weight, ax=ax)
plt.savefig('sankey.png', bbox_inches='tight', dpi=150)
Parameters
| Parameter | Default | Description |
|---|---|---|
left |
required | Labels on the left side |
right |
required | Labels on the right side |
leftWeight |
None |
Weights for each flow (defaults to 1) |
rightWeight |
None |
Right-side weights (defaults to leftWeight) |
colorDict |
None |
Dict mapping labels to colors {'label': 'color'} |
leftLabels |
None |
Custom order for left labels |
rightLabels |
None |
Custom order for right labels |
aspect |
4 |
Vertical extent relative to horizontal |
rightColor |
False |
Color strips by right label instead of left |
grayStrips |
False |
Force all strips to grey |
stripAlpha |
0.65 |
Strip transparency |
palette |
"hls" |
Seaborn palette for auto-coloring |
title |
None |
Diagram title |
fontsize |
12 |
Label font size |
leftLabelhide |
None |
List of left labels to hide |
rightLabelhide |
None |
List of right labels to hide |
ax |
None |
Matplotlib axis to plot on |
figureName |
None |
Save figure to figureName.png (standalone only) |
closePlot |
False |
Close plot after saving (standalone only) |
License
GNU General Public License v3.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matsankey-0.2.2.tar.gz.
File metadata
- Download URL: matsankey-0.2.2.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edef8cf7f310d48cb88be55809c2b6e60343eea434164edbdb5fda439a848c66
|
|
| MD5 |
454b181f172e525cd6850ea30a3bc7fc
|
|
| BLAKE2b-256 |
907957ec01674724235b98e5888bac11cc0076b1ffeb3342dcabc0dd6987803f
|
File details
Details for the file matsankey-0.2.2-py3-none-any.whl.
File metadata
- Download URL: matsankey-0.2.2-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ea43bbeba7093325fa48e743dda59fb43c7aba96b67b09c186ee69fea5e2887
|
|
| MD5 |
9db6c218e75b9119e5f553801ec5ca04
|
|
| BLAKE2b-256 |
06ac3292b1a745ee610d289bf9045b2418b69cdfaa265f00ce51562ad5214a2c
|