A utility library for matplotlib plotting configuration
Project description
PltSci
一个用于简化 matplotlib 绘图参数设置的 Python 工具库。
特性
- 🎨 快速设置科学绘图风格(Times New Roman 字体,内向刻度线等)
- 📏 厘米到英寸的便捷转换工具
- 🎯 简洁的坐标轴范围和刻度设置接口
- ✨ 适用于学术论文和科学报告的图表制作
安装
pip install pltsci
快速开始
from pltsci import whole_plot_set, set_ticks, half_plot_set, cm
import matplotlib.pyplot as plt
import numpy as np
# 设置全局绘图参数
whole_plot_set()
# 创建示例数据
x = np.linspace(0, 10, 100)
y = np.sin(x)
# 创建图形 (使用厘米单位)
fig, ax = plt.subplots(figsize=(cm(12), cm(8)))
ax.plot(x, y, label='sin(x)')
# 设置坐标轴范围和刻度
set_ticks(ax, xrange=(0, 10, 2), yrange=(-1, 1, 0.5))
# 应用精细的轴样式
half_plot_set(ax)
# 添加标签和图例
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.legend()
plt.tight_layout()
plt.show()
API 参考
whole_plot_set(font=None, math_font="stix")
设置全局绘图参数,包括字体、刻度方向、图例样式等。
font: 字体列表,默认为["Times New Roman", "SimSun"]math_font: 数学公式字体,默认为"stix"
set_ticks(ax, xrange=None, yrange=None)
设置坐标轴范围和刻度。
ax: matplotlib 轴对象xrange: x轴范围,格式为(xmin, xmax, xstep)yrange: y轴范围,格式为(ymin, ymax, ystep)
half_plot_set(ax)
设置坐标轴线宽和刻度样式,适用于密集布局的图表。
ax: matplotlib 轴对象
cm / cm_to_inch
厘米到英寸转换工具。
# 两种使用方式
fig, ax = plt.subplots(figsize=(cm(12), cm(8)))
# 或者
fig, ax = plt.subplots(figsize=(cm_to_inch(12), cm_to_inch(8)))
许可证
MIT License - 详见 LICENSE 文件。
贡献
欢迎提交 Issue 和 Pull Request!
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
pltsci-0.1.0.tar.gz
(5.2 kB
view details)
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 pltsci-0.1.0.tar.gz.
File metadata
- Download URL: pltsci-0.1.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ec225e9152104b232f45488b609b0a90c2b3d10198bf4caa0010fd6bba89455
|
|
| MD5 |
d477545fe84dd8d7abae73d638d1dbd0
|
|
| BLAKE2b-256 |
51f100471352b618e47e92aca7843c155357828af2bc2ff116f2a87008b5e028
|
File details
Details for the file pltsci-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pltsci-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1883598e3e37e64e1a799e3e7681289e5e63af4181dcba7fc35adb42689587fe
|
|
| MD5 |
85cda91fe89dc10696ccfe863b99c91f
|
|
| BLAKE2b-256 |
7db90b000cc354629cb53efe5327fe3d75ba004815b1fc66a2a5b04293acbb65
|