simpleplot-lite 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ """simpleplot_lite —— 一个简单的画图工具包。"""
2
+
3
+ from .charts import bar_chart, line_chart, pie_chart
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ __all__ = ["line_chart", "bar_chart", "pie_chart", "__version__"]
@@ -0,0 +1,62 @@
1
+ """simpleplot_lite.charts —— 三个最常用的画图函数。
2
+
3
+ 全部基于 matplotlib,每个函数都会返回一个 Figure 对象,
4
+ 可以继续自己修改,也可以传 save_path 直接保存成图片。
5
+ """
6
+
7
+ import matplotlib
8
+ import matplotlib.pyplot as plt
9
+
10
+ # Windows 下中文默认会显示成方框,这里指定可用字体
11
+ matplotlib.rcParams["font.sans-serif"] = ["Microsoft YaHei", "SimHei", "DejaVu Sans"]
12
+ matplotlib.rcParams["axes.unicode_minus"] = False
13
+
14
+
15
+ def line_chart(x, y, title="折线图", xlabel="x", ylabel="y", save_path=None):
16
+ """画折线图,x 和 y 是长度相同的列表。"""
17
+ if len(x) != len(y):
18
+ raise ValueError("x 和 y 的长度必须相同")
19
+
20
+ fig, ax = plt.subplots(figsize=(6, 4))
21
+ ax.plot(x, y, marker="o", color="tab:blue")
22
+ ax.set_title(title)
23
+ ax.set_xlabel(xlabel)
24
+ ax.set_ylabel(ylabel)
25
+ ax.grid(True, linestyle="--", alpha=0.5)
26
+
27
+ if save_path:
28
+ fig.savefig(save_path, dpi=120, bbox_inches="tight")
29
+ return fig
30
+
31
+
32
+ def bar_chart(labels, values, title="柱状图", xlabel="类别", ylabel="数值", save_path=None):
33
+ """画柱状图,labels 是类别名,values 是对应的数值。"""
34
+ if len(labels) != len(values):
35
+ raise ValueError("labels 和 values 的长度必须相同")
36
+
37
+ fig, ax = plt.subplots(figsize=(6, 4))
38
+ bars = ax.bar(labels, values, color="tab:orange")
39
+ ax.set_title(title)
40
+ ax.set_xlabel(xlabel)
41
+ ax.set_ylabel(ylabel)
42
+ ax.bar_label(bars) # 在柱子顶部显示数值
43
+ ax.grid(True, axis="y", linestyle="--", alpha=0.5)
44
+
45
+ if save_path:
46
+ fig.savefig(save_path, dpi=120, bbox_inches="tight")
47
+ return fig
48
+
49
+
50
+ def pie_chart(labels, values, title="饼图", save_path=None):
51
+ """画饼图,会自动计算百分比。"""
52
+ if len(labels) != len(values):
53
+ raise ValueError("labels 和 values 的长度必须相同")
54
+
55
+ fig, ax = plt.subplots(figsize=(5, 5))
56
+ ax.pie(values, labels=labels, autopct="%1.1f%%", startangle=90)
57
+ ax.set_title(title)
58
+ ax.axis("equal") # 保证饼是圆的
59
+
60
+ if save_path:
61
+ fig.savefig(save_path, dpi=120, bbox_inches="tight")
62
+ return fig
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: simpleplot-lite
3
+ Version: 0.1.0
4
+ Summary: 一个简单的 Python 画图工具包,封装折线图、柱状图和饼图
5
+ Author-email: Your Name <you@example.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/yourname/simpleplot-lite
8
+ Keywords: plot,chart,matplotlib,visualization
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Scientific/Engineering :: Visualization
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: matplotlib>=3.5
16
+ Provides-Extra: dev
17
+ Requires-Dist: build; extra == "dev"
18
+ Requires-Dist: twine; extra == "dev"
19
+ Dynamic: license-file
20
+
21
+ # simpleplot-lite
22
+
23
+ 一个简单的 Python 画图工具包,把 matplotlib 最常用的三种图表封装成一行调用。
24
+ 适合刚学 Python 的同学快速画图。
25
+
26
+ ## 功能
27
+
28
+ - `line_chart(x, y, ...)`:折线图
29
+ - `bar_chart(labels, values, ...)`:柱状图
30
+ - `pie_chart(labels, values, ...)`:饼图
31
+
32
+ 每个函数都支持 `title`、`xlabel`、`ylabel`(饼图没有坐标轴)和 `save_path`,
33
+ 返回值是 matplotlib 的 `Figure` 对象,可以继续自己修改。
34
+
35
+ ## 安装
36
+
37
+ ```bash
38
+ pip install simpleplot-lite
39
+ ```
40
+
41
+ ## 快速开始
42
+
43
+ ```python
44
+ from simpleplot_lite import line_chart, bar_chart, pie_chart
45
+
46
+ # 折线图:保存成图片
47
+ line_chart([1, 2, 3, 4], [60, 72, 68, 85],
48
+ title="四次小测成绩", xlabel="次数", ylabel="分数",
49
+ save_path="line.png")
50
+
51
+ # 柱状图
52
+ bar_chart(["Python", "C++", "Java"], [90, 80, 70],
53
+ title="编程语言喜好", save_path="bar.png")
54
+
55
+ # 饼图
56
+ pie_chart(["吃饭", "睡觉", "写代码"], [3, 8, 13],
57
+ title="一天的时间分配", save_path="pie.png")
58
+ ```
59
+
60
+ ## 项目结构
61
+
62
+ ```
63
+ simpleplot-lite/
64
+ ├── LICENSE
65
+ ├── README.md
66
+ ├── pyproject.toml
67
+ ├── demo.py # 运行后生成三张示例图片
68
+ ├── simpleplot_lite/
69
+ │ ├── __init__.py
70
+ │ └── charts.py
71
+ └── tests/
72
+ └── test_charts.py
73
+ ```
74
+
75
+ ## 打包发布步骤
76
+
77
+ ```bash
78
+ # 1. 安装打包工具
79
+ pip install build twine
80
+
81
+ # 2. 运行测试
82
+ python -m unittest discover -s tests -v
83
+
84
+ # 3. 构建,产物在 dist/ 目录
85
+ python -m build
86
+
87
+ # 4. 检查元数据
88
+ twine check dist/*
89
+
90
+ # 5. 先上传到 TestPyPI 测试
91
+ twine upload --repository testpypi dist/*
92
+
93
+ # 6. 再上传到正式 PyPI
94
+ twine upload dist/*
95
+ ```
96
+
97
+ 上传时用户名填 `__token__`,密码填 PyPI 网站生成的 API Token(`pypi-` 开头)。
98
+
99
+ 注意:同一个版本号不能重复上传,重新发布前要把 `pyproject.toml` 和
100
+ `simpleplot_lite/__init__.py` 里的版本号一起改大,并删除旧的 `dist/` 目录。
101
+
102
+ ## License
103
+
104
+ MIT
@@ -0,0 +1,7 @@
1
+ simpleplot_lite/__init__.py,sha256=AOszVMpV7FlmA-Tnq9Nem2NMmumzg_uF_jbzsaVhkO8,207
2
+ simpleplot_lite/charts.py,sha256=ewYkqLG8U0Lxyqfb3Bj4kJjOIaoZgXzQYR_TNq-aWRg,2228
3
+ simpleplot_lite-0.1.0.dist-info/licenses/LICENSE,sha256=v2spsd7N1pKFFh2G8wGP_45iwe5S0DYiJzG4im8Rupc,1066
4
+ simpleplot_lite-0.1.0.dist-info/METADATA,sha256=pxWO8Q5SgMohK9ADDJHL6o3nX4ptsnlaSJhGZoWgdwU,2848
5
+ simpleplot_lite-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
6
+ simpleplot_lite-0.1.0.dist-info/top_level.txt,sha256=81vxEBl_M6xxIH_kBfm7hPtA3wgqTzPNkbaTErPeu1U,16
7
+ simpleplot_lite-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ simpleplot_lite