Skip to main content

Sunmao

PyPI version Documentation Status Python Support License: MIT

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:

  1. create(figsize=...) → (fig, root), same pattern as plt.subplots
  2. root.tenon(pos, size) → new panel; size is in inches
  3. .ax → standard matplotlib.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


Basic layout Nested panels
basic nested
Genome browser seaborn / scanpy
genomics thirdparty
ComplexHeatmap style OncoPrint style
complexheatmap oncoprint
Multi-omics integration
multiomics

License

MIT

Metadata

Release files for sunmao 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sunmao 0.6.0
File Size Uploaded Provenance
sunmao-0.6.0.tar.gz 7.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sunmao 0.6.0
File Interpreter ABI Platform
sunmao-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / sunmao-0.6.0.tar.gz

Download URL sunmao-0.6.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d64796632c31eb286e2ba47ce6127b411b6a272c70dafff13893737319b01011
BLAKE2b-256 checksum
How to use checksums
ed96b55d241edb67475472dbd680e1c0e28ed87a9170d1c760aa004352c03663
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sunmao-0.6.0-py3-none-any.whl

Download URL sunmao-0.6.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fa2af0b1e9ac59f06f85e8ead2ef1744303f7eee2668c96c9663d93b33d11ad1
BLAKE2b-256 checksum
How to use checksums
d09c7ee17415cd70779ad6a54bb69793dbcb4e411ac439f6026574847239ee84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for sunmao 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page