Skip to main content

YuMeow's personal matplotlib wrappers for academic and daily use.

Project description

🐾 yumeow-plot

YuMeow's personal matplotlib wrappers for academic and daily use.

yumeow-plot 是一套专为科研绘图设计的 Matplotlib 封装库。它专注于解决论文投稿中常见的物理尺寸对齐空间布局分配等痛点。


✨ 核心特性

  • 📏 精确尺寸求解 (Sizing Solver):直接使用厘米 (cm) 定义画布或子图大小,自动计算间距,完美适配不同期刊会议的分栏要求。
  • 🧠 空间感应轴 (Space-aware Axes):通过 ax.get_side_rect() 探测子图周边区域,实现 Colorbar 或标注区域的毫米级对齐。
  • 🧩 智能合并布局 (Smart Merging):告别复杂的 GridSpec,通过 merge_axes 像 Excel 合并单元格一样调整布局。
  • 🛡️ 局部样式隔离:使用局部 rc_context 应用学术风配置,绝不污染全局绘图设置。
  • 📈 高阶可视化补丁:内置 plot_resilience (相平面韧性分析) 和 plotOD (地理流向图) 等高级功能。

🚀 快速开始

安装

pip install yumeow-plot

基础用法:精确控制子图尺寸

import yumeow_plot as ym
import matplotlib.pyplot as plt

# 创建一个 1x2 布局,强制每个子图宽度为 4cm,高度按比例自动计算
fig, axes = ym.get_fig(1, 2, AW=4, A_ratio=1.2)

axes[0].plot([1, 2, 3], [4, 5, 6])
axes[1].scatter([1, 2, 3], [6, 5, 4])

# 在子图右侧自动分配一个 0.2cm 宽的区域放置 Colorbar
cax_rect = axes[1].get_side_rect(side='right', fixed_cm=0.2, pad_cm=0.1)
cax = fig.add_axes(cax_rect)

进阶:合并子图

# 生成 3x3 网格
fig, axes = ym.get_fig(3, 3, AW=3, AH=3)

# 将左上角 2x2 的子图合并为一个大图
big_ax = ym.merge_axes(axes.reshape(3,3)[:2, :2])

# 大图依然保留空间探测能力
title_rect = big_ax.get_side_rect(side='top', fixed_cm=0.5)

🎨 高级可视化

韧性分析图 (Resilience Plot)

针对二维系统动态特性的快速可视化工具。

from yumeow_plot import plot_resilience

f = lambda x, y: y - 3*y**2 - y**3 + x*y**3
plot_resilience(f, extent=(0, 5, 0, 5))

地理流向图 (OD Flow)

支持多种曲线样式的起终点流量可视化。

from yumeow_plot import plotOD

# 支持 'straight', 'parabola', 'rotated_parabola' 等多种轨迹
plotOD(ax, source, destination, flow, location, linetype='parabola')

📂 项目结构

yumeow-plot/
├── yumeow_plot/
│   ├── figure.py      # get_fig, merge_axes (物理布局)
│   ├── layout.py      # get_side_rect, get_margin_rect (空间探测)
│   ├── utils.py       # 字体加载与底层转换
│   └── advanced_viz/  # 高级绘图函数 (OD, Resilience)
├── demo/              # 示例代码目录
├── pyproject.toml     # 项目元数据
└── LICENSE            # MIT License

⚖️ License

本项目采用 MIT License

Copyright (c) 2026 YuMeow

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yumeow_plot-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

yumeow_plot-0.1.0-py2.py3-none-any.whl (13.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file yumeow_plot-0.1.0.tar.gz.

File metadata

  • Download URL: yumeow_plot-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.4

File hashes

Hashes for yumeow_plot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f73817e485ee9ebf9f4d5b6d8753bb2cfa38fbc214ab3428e6df36076f27c1e3
MD5 933437d9019e4073f57de06bb07b11c6
BLAKE2b-256 59e2808e477a9f54771d23c30b48b8c2def192c06fc7270a9d327ed95aa556d9

See more details on using hashes here.

File details

Details for the file yumeow_plot-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: yumeow_plot-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.4

File hashes

Hashes for yumeow_plot-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 642a28b8ad8539b2ed853c07d7664c15c397a50bdd2d77c2bcf85b733e14ae9d
MD5 2eb7bd14ad29b5c544caf29b9f80d0c6
BLAKE2b-256 f391decdcd8946a3bd84e4d01e61c5ee327dc4f626f88cebc6e0475d89c174f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page