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


Gallery Preview

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

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

sunmao-0.6.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sunmao-0.6.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

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

Hashes for sunmao-0.6.0.tar.gz
Algorithm Hash digest
SHA256 d64796632c31eb286e2ba47ce6127b411b6a272c70dafff13893737319b01011
MD5 9539b2b4da04142c9aab957bb54137ac
BLAKE2b-256 ed96b55d241edb67475472dbd680e1c0e28ed87a9170d1c760aa004352c03663

See more details on using hashes here.

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

Hashes for sunmao-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa2af0b1e9ac59f06f85e8ead2ef1744303f7eee2668c96c9663d93b33d11ad1
MD5 22c3ea48431868d51358dfa37d33c7df
BLAKE2b-256 d09c7ee17415cd70779ad6a54bb69793dbcb4e411ac439f6026574847239ee84

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 files

0.5.1

2 files

0.3.3

2 files

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