Sunmao
A matplotlib layout library inspired by traditional Chinese mortise-tenon (榫卯) joinery.
Attach panels in any direction, get a standard ax, use any plotting library.
Install
pip install sunmao
Quick Start
from sunmao import create
import numpy as np
fig, root = create(figsize=(10, 8))
top = root.tenon('top', size=2) # 2-inch tall panel above root
right = root.tenon('right', size=3) # 3-inch wide panel to the right
x = np.linspace(0, 10, 100)
root.ax.plot(x, np.sin(x))
top.ax.bar(range(8), np.random.rand(8))
right.ax.scatter(np.random.randn(50), np.random.randn(50))
fig.savefig('out.png', bbox_inches='tight')
Three things to know:
create(figsize=...)→(fig, root), same pattern asplt.subplotsroot.tenon(pos, size)→ new panel;sizeis in inches.ax→ standardmatplotlib.axes.Axes, works with any library
Layout Model
figsize = (10, 8)
┌─────────────────────────────────┐
│ top (size=2) │
├──────────────────────┬──────────┤
│ │ right │
│ root │ (size=3) │
│ │ │
└──────────────────────┴──────────┘
size is always in inches — no percentages, no ratios.
If you want a panel that is 25% of figure height: size = figsize[1] * 0.25.
Nesting
Any panel can have its own children:
fig, root = create(figsize=(12, 8))
top = root.tenon('top', size=3)
top_left = top.tenon('left', size=3) # child of top
top_right = top.tenon('right', size=3) # child of top
Third-Party Integration
import seaborn as sns
import scanpy as sc
fig, root = create(figsize=(12, 8))
right = root.tenon('right', size=4)
sc.pl.umap(adata, ax=root.ax, show=False)
sns.violinplot(data=df, ax=right.ax)
fig.savefig('out.png', bbox_inches='tight')
trackc (genome browser)
import trackc.pl as pl
from sunmao import create
fig, scale = create(figsize=(12, 9))
signal = scale.tenon('top', size=1.5, pad=0.05)
genes = scale.tenon('top', size=1.5, pad=0.05)
hic = scale.tenon('top', size=3.0, pad=0.05)
region = 'chr18:47950000-48280000'
pl.bw_track(bw='signal.bw', ax=signal.ax, regions=region)
pl.gene_track(ax=genes.ax, bed12='genes.bed12', regions=region)
pl.mapC(mat=hic_mat, ax=hic.ax)
pl.scale_track(ax=scale.ax, region=region)
fig.savefig('genome_browser.png', bbox_inches='tight')
Documentation
- Usage Guide — full API reference and examples
- Gallery — visual examples with code
Gallery Preview
| Basic layout | Nested panels |
|---|---|
| Genome browser | seaborn / scanpy |
|---|---|
| ComplexHeatmap style | OncoPrint style |
|---|---|
| Multi-omics integration | |
|---|---|
License
MIT
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 sunmao-0.6.0.tar.gz.
File metadata
- Download URL: sunmao-0.6.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d64796632c31eb286e2ba47ce6127b411b6a272c70dafff13893737319b01011
|
|
| MD5 |
9539b2b4da04142c9aab957bb54137ac
|
|
| BLAKE2b-256 |
ed96b55d241edb67475472dbd680e1c0e28ed87a9170d1c760aa004352c03663
|
File details
Details for the file sunmao-0.6.0-py3-none-any.whl.
File metadata
- Download URL: sunmao-0.6.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa2af0b1e9ac59f06f85e8ead2ef1744303f7eee2668c96c9663d93b33d11ad1
|
|
| MD5 |
22c3ea48431868d51358dfa37d33c7df
|
|
| BLAKE2b-256 |
d09c7ee17415cd70779ad6a54bb69793dbcb4e411ac439f6026574847239ee84
|