Skip to main content

High-Performance Structured Figure Engine

Project description

FigEngine 🎨

PyPI version Python versions License Documentation

A High-Performance Structured Figure Engine for Python. FigEngine 是一个专为科研工作者设计的 Python 绘图排版引擎。它封装了 PIL 和 Matplotlib,让你能够以物理单位(英寸、厘米)精确控制图片的排版、缩放和标注,轻松生成用于论文发表的高质量组合图(Figure)。 不再为 matplotlib 的 subplot 坐标烦恼,也不用在 PPT 里手动对齐图片——FigEngine 帮你搞定。

✨ 核心特性

  • 📏 物理单位感知:原生支持 inch, cm, mm,所见即所得。
  • 🏷️ 智能标注:一键生成 (a), (b), Fig. 1 等符合期刊格式的子图编号。
  • 🧩 自动排版引擎:基于行(Row)的流式布局,自动计算间距和对齐。
  • ✒️ 丰富的绘图能力:支持 LaTeX 公式、箭头、几何标记、比例尺刻度。
  • 🔍 字体管理:内置系统字体探查工具,轻松查找并使用中文字体。

🛠️ 安装

从 GitHub 安装最新开发版 (暂时推荐)

pip install git+https://github.com/wubulks/FigEngine.git

通过PyPI安装

pip install figengine

🚀 快速开始

1. Hello World:创建并标注一张图片

import figengine as fe
# 创建一个 4x3 英寸的空白画布
img = fe.Image.new(size=(4, 3), unit="inch", facecolor="#E0E0E0")
# 自动添加子图编号 "(a)",默认位于左上角
img = img.labeled("a", fontsize=24)
# 添加一段文字 (支持 LaTeX)
img = img.add_text(r"$\sum_{i=0}^\infty x_i$", position="center", fontsize=40)
# 在 Jupyter 中预览 (自动缩放以适应屏幕)
img.show()

2. 组合排版 (Figure Layout)

这是 FigEngine 最强大的功能。我们可以轻松地将多张图片拼接成一个 Figure。

import figengine as fe
# 1. 初始化排版器 (设定画布宽度为 12 英寸)
fig = fe.Figure(width=12, unit="inch", background="white")
# 2. 准备素材 (这里使用生成的图片演示,也可以使用 fe.Image("path/to/file.png"))
img_a = fe.Image.new((4, 3), unit="inch", facecolor="#FFB8CD").labeled("a")
img_b = fe.Image.new((4, 3), unit="inch", facecolor="#87CEEB").labeled("b")
img_c = fe.Image.new((8, 2), unit="inch", facecolor="#98FB98").labeled("c")
# 3. 添加第一行:两张图片并排,中间留 0.1 英寸间隙
fig.add_row([img_a, img_b], left_gaps=0.0, right_gaps=0.1, unit="inch")
# 4. 添加第二行:一张长图,顶部与上一行留 0.2 英寸间隙
fig.add_row([img_c], top_margin=0.2, unit="inch", v_align="center")
# 5. 渲染并显示
fig.image.show(width=500)
# 6. 保存为高清图片
fig.image.save("output_figure.png")
fig.image.save("output_figure.pdf")

功能详解请参阅用户手册 User Manual (PDF): FigEngine用户手册(https://github.com/wubulks/FigEngine/blob/main/doc/FigEngine用户手册.pdf)


🤝 贡献指南

欢迎提交 Issue 和 Pull Request!

  1. Fork 本仓库。
  2. 创建你的特性分支 (git checkout -b feature/AmazingFeature)。
  3. 提交你的修改 (git commit -m 'Add some AmazingFeature')。
  4. 推送到分支 (git push origin feature/AmazingFeature)。
  5. 打开一个 Pull Request。

📄 许可证

本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。

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

figengine-1.0.2.tar.gz (50.5 kB view details)

Uploaded Source

Built Distribution

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

figengine-1.0.2-py3-none-any.whl (55.6 kB view details)

Uploaded Python 3

File details

Details for the file figengine-1.0.2.tar.gz.

File metadata

  • Download URL: figengine-1.0.2.tar.gz
  • Upload date:
  • Size: 50.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for figengine-1.0.2.tar.gz
Algorithm Hash digest
SHA256 57b4386d9a5ac9c7aadf284f513bbd2b5d912b69b976279f73d719bf13cf892b
MD5 dce5447d1576d6e80fcdbfd0a3b52c84
BLAKE2b-256 318126b0ce2aedc1ec722329cad747ba7dcae7595a2b1bf1d644d6659d679b64

See more details on using hashes here.

File details

Details for the file figengine-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: figengine-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 55.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for figengine-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 adccca96f7bfa64e4cea6b7112acf138bd9f761f41ba300c2cdd311d2c1f7b77
MD5 0b5623b42a3333be959bc5e10f4af516
BLAKE2b-256 7520deda710afbef2dff807c582376a08e0d8de1ea8c126aa71e58dc2bc28f9f

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