paperplotter 0.1.1__tar.gz → 0.1.2__tar.gz
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.
- paperplotter-0.1.2/MANIFEST.in +2 -0
- paperplotter-0.1.2/PKG-INFO +149 -0
- paperplotter-0.1.2/README.md +125 -0
- paperplotter-0.1.2/examples/advanced_customization_figure.png +0 -0
- paperplotter-0.1.2/examples/advanced_layout_figure.png +0 -0
- paperplotter-0.1.2/examples/aesthetic_and_processing_example.png +0 -0
- paperplotter-0.1.2/examples/aspect_ratio_mosaic.png +0 -0
- paperplotter-0.1.2/examples/aspect_ratio_simple_grid.png +0 -0
- paperplotter-0.1.2/examples/block_span_figure.png +0 -0
- paperplotter-0.1.2/examples/cleanup_demonstration_figure.png +0 -0
- paperplotter-0.1.2/examples/composite_figure.png +0 -0
- paperplotter-0.1.2/examples/concentration_map_example.png +0 -0
- paperplotter-0.1.2/examples/data_analysis_utils_example.png +0 -0
- paperplotter-0.1.2/examples/domain_specific_plots.png +0 -0
- paperplotter-0.1.2/examples/feature_expansion_figure.png +0 -0
- paperplotter-0.1.2/examples/global_controls_figure.png +0 -0
- paperplotter-0.1.2/examples/heatmap_default_figure.png +0 -0
- paperplotter-0.1.2/examples/heatmap_shared_colorbar_figure.png +0 -0
- paperplotter-0.1.2/examples/learning_curve_example.png +0 -0
- paperplotter-0.1.2/examples/multi_plot_grid_figure.png +0 -0
- paperplotter-0.1.2/examples/power_timeseries_example.png +0 -0
- paperplotter-0.1.2/examples/presentation_style_figure.png +0 -0
- paperplotter-0.1.2/examples/publication_style_figure.png +0 -0
- paperplotter-0.1.2/examples/resources/placeholder_image.png +0 -0
- paperplotter-0.1.2/examples/row_span_figure.png +0 -0
- paperplotter-0.1.2/examples/statistical_annotation_example.png +0 -0
- paperplotter-0.1.2/examples/style_gallery_flat.png +0 -0
- paperplotter-0.1.2/examples/style_gallery_nord.png +0 -0
- paperplotter-0.1.2/examples/style_gallery_presentation.png +0 -0
- paperplotter-0.1.2/examples/style_gallery_publication.png +0 -0
- paperplotter-0.1.2/examples/style_gallery_solarized_light.png +0 -0
- paperplotter-0.1.2/examples/utility_functions_example.png +0 -0
- paperplotter-0.1.2/paperplot/styles/flat.mplstyle +40 -0
- paperplotter-0.1.2/paperplot/styles/nord.mplstyle +44 -0
- paperplotter-0.1.2/paperplot/styles/presentation.mplstyle +41 -0
- paperplotter-0.1.2/paperplot/styles/publication.mplstyle +24 -0
- paperplotter-0.1.2/paperplot/styles/solarized_light.mplstyle +44 -0
- paperplotter-0.1.2/paperplotter.egg-info/PKG-INFO +149 -0
- paperplotter-0.1.2/paperplotter.egg-info/SOURCES.txt +71 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/pyproject.toml +4 -2
- paperplotter-0.1.1/PKG-INFO +0 -150
- paperplotter-0.1.1/README.md +0 -126
- paperplotter-0.1.1/paperplotter.egg-info/PKG-INFO +0 -150
- paperplotter-0.1.1/paperplotter.egg-info/SOURCES.txt +0 -36
- {paperplotter-0.1.1 → paperplotter-0.1.2}/LICENSE +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Data_Analysis_Utils}/data_analysis_utils_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Data_Analysis_Utils}/utility_functions_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Domain_Specific_Plots}/bifurcation_diagram_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Domain_Specific_Plots}/concentration_map_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Domain_Specific_Plots}/domain_specific_plots_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Domain_Specific_Plots}/learning_curve_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Domain_Specific_Plots}/phasor_diagram_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Domain_Specific_Plots}/power_timeseries_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/advanced_customization.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/cleanup_demonstration.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/composite_figure_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/error_handling_test.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/feature_expansion_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/global_controls_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/heatmap_colorbar_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Features_Customization}/multi_plot_grid.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Layout}/advanced_layout_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Layout}/aspect_ratio_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Layout}/block_span_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Layout}/row_span_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Styles_Aesthetics}/aesthetic_and_processing_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Styles_Aesthetics}/statistical_annotation_example.py +0 -0
- {paperplotter-0.1.1/examples → paperplotter-0.1.2/examples/Styles_Aesthetics}/style_gallery_example.py +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/paperplot/__init__.py +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/paperplot/core.py +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/paperplot/exceptions.py +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/paperplot/utils.py +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/paperplotter.egg-info/dependency_links.txt +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/paperplotter.egg-info/requires.txt +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/paperplotter.egg-info/top_level.txt +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/setup.cfg +0 -0
- {paperplotter-0.1.1 → paperplotter-0.1.2}/tests/test_plotter.py +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: paperplotter
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: 一个为科研论文设计的声明式 Matplotlib 封装库,让复杂图表的创建变得简单直观。
|
|
5
|
+
Author-email: VerNe <yuu_seeing@foxmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ID-VerNe/PaperPlot
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/ID-VerNe/PaperPlot/issues
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Framework :: Matplotlib
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
18
|
+
Requires-Dist: numpy>=1.21.0
|
|
19
|
+
Requires-Dist: pandas>=1.3.0
|
|
20
|
+
Requires-Dist: seaborn>=0.11.0
|
|
21
|
+
Requires-Dist: scipy==1.16.3
|
|
22
|
+
Requires-Dist: adjustText==1.3.0
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# PaperPlot
|
|
26
|
+
|
|
27
|
+
[](https://badge.fury.io/py/paperplotter)
|
|
28
|
+
[](https://opensource.org/licenses/MIT)
|
|
29
|
+
|
|
30
|
+
**一个为科研论文设计的声明式 Matplotlib 封装库,让复杂图表的创建变得简单直观。**
|
|
31
|
+
|
|
32
|
+
`PaperPlot` 的诞生是为了解决在准备学术论文时,使用 Matplotlib 创建高质量、布局复杂的图表所面临的繁琐问题。它通过引入声明式的链式 API 和基于标签(tag)的对象管理,让你能够用更少的代码,更清晰的逻辑,构建从简单网格到复杂组合的各类图表。
|
|
33
|
+
|
|
34
|
+
## 核心理念与特性
|
|
35
|
+
|
|
36
|
+
* **🎨 声明式链式调用**: 像写句子一样构建你的图表,例如 `plotter.add_line(...).set_title(...).set_xlabel(...)`。
|
|
37
|
+
* **🏷️ 基于标签的控制**: 给每个子图一个独一无二的 `tag`,之后就可以随时通过 `tag` 对其进行任何修改,告别混乱的 `axes[i][j]` 索引。
|
|
38
|
+
* **🧩 强大的布局系统**: 无论是简单的 `(行, 列)` 网格,还是使用 `subplot_mosaic` 实现的跨行跨列复杂布局,都能轻松定义。
|
|
39
|
+
* **✨ 内置科研主题**: 提供多种专业美观的内置样式,如 `publication`, `presentation` 等,一键切换图表风格。
|
|
40
|
+
* **🔬 丰富的领域专用图表**: 内置了科研中常用的图表类型,如光谱图、混淆矩阵、ROC 曲线、学习曲线、分岔图、相量图等。
|
|
41
|
+
* **🔧 智能美化工具**: `cleanup()` 方法可以智能地共享坐标轴、对齐标签;`cleanup_heatmaps()` 可以为多个热图创建共享的颜色条。
|
|
42
|
+
|
|
43
|
+
## 安装
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install paperplotter
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 快速开始
|
|
50
|
+
|
|
51
|
+
只需几行代码,就可以创建一个包含两个子图的 1x2 网格图。
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
import paperplot as pp
|
|
55
|
+
import pandas as pd
|
|
56
|
+
import numpy as np
|
|
57
|
+
|
|
58
|
+
# 1. 准备数据
|
|
59
|
+
df_line = pd.DataFrame({
|
|
60
|
+
'time': np.linspace(0, 10, 50),
|
|
61
|
+
'signal': np.cos(np.linspace(0, 10, 50))
|
|
62
|
+
})
|
|
63
|
+
df_scatter = pd.DataFrame({
|
|
64
|
+
'x': np.random.rand(50) * 10,
|
|
65
|
+
'y': np.random.rand(50) * 10
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
# 2. 初始化 Plotter 并绘图
|
|
69
|
+
plotter = pp.Plotter(layout=(1, 2), figsize=(10, 4))
|
|
70
|
+
|
|
71
|
+
# 3. 添加图表并使用 tag 标记
|
|
72
|
+
plotter.add_line(data=df_line, x='time', y='signal', tag='time_series')
|
|
73
|
+
plotter.add_scatter(data=df_scatter, x='x', y='y', tag='scatter_plot')
|
|
74
|
+
|
|
75
|
+
# 4. 通过 tag 设置标题和标签
|
|
76
|
+
plotter.set_title('time_series', 'Time Series Data')
|
|
77
|
+
plotter.set_xlabel('time_series', 'Time (s)')
|
|
78
|
+
plotter.set_ylabel('time_series', 'Signal')
|
|
79
|
+
|
|
80
|
+
plotter.set_title('scatter_plot', 'Scatter Plot')
|
|
81
|
+
plotter.set_xlabel('scatter_plot', 'X Value')
|
|
82
|
+
plotter.set_ylabel('scatter_plot', 'Y Value')
|
|
83
|
+
|
|
84
|
+
# 5. 保存图像
|
|
85
|
+
plotter.save("quick_start_figure.png")
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## 通过示例学习 (Learn from Examples)
|
|
90
|
+
|
|
91
|
+
掌握 `PaperPlot` 最好的方法就是探索我们提供的丰富示例。每个示例都专注于一个核心功能,并附有详细的代码和注释。
|
|
92
|
+
|
|
93
|
+
### 布局 (Layout)
|
|
94
|
+
|
|
95
|
+
| 示例 | 描述 | 关键功能 |
|
|
96
|
+
| :--- | :--- | :--- |
|
|
97
|
+
| **高级布局**<br/> `Layout/advanced_layout_example.py` | 展示如何使用列表定义一个跨列的复杂布局。 | `layout=[['A', 'B', 'B'], ...]`<br/>`get_ax_by_name()` |
|
|
98
|
+
| **行跨越**<br/> `Layout/row_span_example.py` | 创建一个图表,其中某个子图跨越多行。 | `layout=[['A', 'B'], ['A', 'C']]` |
|
|
99
|
+
| **块跨越**<br/> `Layout/block_span_example.py` | 创建一个图表,其中某个子图同时跨越多行和多列。 | `layout=[['A', 'A', 'B'], ['A', 'A', 'C']]` |
|
|
100
|
+
| **固定子图宽高比**<br/> `Layout/aspect_ratio_example.py` | 在不指定 `figsize` 的情况下,通过 `subplot_aspect` 保证每个子图单元格的宽高比,Plotter 会自动计算画布大小。 | `subplot_aspect=(16, 9)` |
|
|
101
|
+
|
|
102
|
+
### 功能与定制化 (Features & Customization)
|
|
103
|
+
|
|
104
|
+
| 示例 | 描述 | 关键功能 |
|
|
105
|
+
| :--- | :--- | :--- |
|
|
106
|
+
| **多图网格**<br/> `Features_Customization/multi_plot_grid.py` | 在一个网格中混合绘制不同类型的图表(线图、柱状图、散点图、热图)。 | `add_line()`, `add_bar()`, `add_scatter()`, `add_heatmap()` |
|
|
107
|
+
| **高级定制**<br/> `Features_Customization/advanced_customization.py` | 演示如何使用 `get_ax()` "逃生舱口" 来获取原生的 Matplotlib `Axes` 对象,并添加任意 `Patch`(如椭圆)。 | `get_ax()`, `ax.add_patch()` |
|
|
108
|
+
| **全局控制**<br/> `Features_Customization/global_controls_example.py` | 展示如何设置全局标题 (`suptitle`) 和创建全局图例。 | `set_suptitle()`, `add_global_legend()` |
|
|
109
|
+
| **共享颜色条**<br/> `Features_Customization/heatmap_colorbar_example.py` | 为多个热图创建一个共享的、能反映全局数据范围的颜色条。 | `add_heatmap(cbar=False)`, `cleanup_heatmaps()` |
|
|
110
|
+
| **智能清理**<br/> `Features_Customization/cleanup_demonstration.py` | 演示 `cleanup()` 函数如何动态地为指定行/列的子图共享 X/Y 轴,并自动隐藏多余的刻度标签。 | `cleanup(share_y_on_rows=...)`, `cleanup(share_x_on_cols=...)` |
|
|
111
|
+
| **组合图与内嵌图**<br/> `Features_Customization/composite_figure_example.py` | 创建一个 L 型的复杂图表,并在其中一个子图内部嵌入一张图片。 | `layout=[['A', 'A'], ['B', '.']]`, `add_inset_image()` |
|
|
112
|
+
| **功能扩展**<br/> `Features_Customization/feature_expansion_example.py` | 演示双Y轴 (`add_twinx`)、回归图 (`add_regplot`)、参考线 (`add_hline`) 和文本标注 (`add_text`) 等高级功能。 | `add_twinx()`, `add_regplot()`, `add_hline()`, `add_text()` |
|
|
113
|
+
| **错误处理**<br/> `Features_Customization/error_handling_test.py` | 展示 `PaperPlot` 的自定义异常,如 `DuplicateTagError`, `TagNotFoundError`, `PlottingSpaceError`。 | `try...except pp.PaperPlotError` |
|
|
114
|
+
|
|
115
|
+
### 风格与美化 (Styles & Aesthetics)
|
|
116
|
+
|
|
117
|
+
| 示例 | 描述 | 关键功能 |
|
|
118
|
+
| :--- | :--- | :--- |
|
|
119
|
+
| **风格画廊**<br/> `Styles_Aesthetics/style_gallery_example.py` | 循环遍历所有内置的绘图风格,并为每种风格生成一个示例图。 | `Plotter(style='...')` |
|
|
120
|
+
| **统计标注**<br/> `Styles_Aesthetics/statistical_annotation_example.py` | 在箱线图上自动进行多组成对统计检验(如 t-test),并智能堆叠显著性标记。 | `add_box()`, `utils.add_pairwise_tests()` |
|
|
121
|
+
| **美学与处理**<br/> `Styles_Aesthetics/aesthetic_and_processing_example.py` | 使用 `utils` 模块中的函数对数据进行平滑处理或根据条件高亮特定数据点。 | `utils.moving_average()`, `utils.highlight_points()` |
|
|
122
|
+
|
|
123
|
+
### 领域专用图 (Domain-Specific Plots)
|
|
124
|
+
|
|
125
|
+
| 示例 | 描述 | 关键功能 |
|
|
126
|
+
| :--- | :--- | :--- |
|
|
127
|
+
| **领域专用图合集**<br/> `Domain_Specific_Plots/domain_specific_plots_example.py` | 一站式展示多种领域专用图,包括 SERS 光谱图、混淆矩阵、ROC 曲线和 PCA 散点图。 | `add_spectra()`, `add_confusion_matrix()`, `add_roc_curve()`, `add_pca_scatter()` |
|
|
128
|
+
| **学习曲线**<br/> `Domain_Specific_Plots/learning_curve_example.py` | 绘制机器学习模型的学习曲线,帮助诊断过拟合或欠拟合问题。 | `utils.plot_learning_curve()` |
|
|
129
|
+
| **SERS 浓度图**<br/> `Domain_Specific_Plots/concentration_map_example.py` | 绘制 SERS Mapping 浓度图,本质上是带有专业美化的热图。 | `add_concentration_map()` |
|
|
130
|
+
| **电力系统时间序列**<br/> `Domain_Specific_Plots/power_timeseries_example.py` | 绘制电力系统动态仿真结果,并自动标记故障、切除等事件。 | `add_power_timeseries()` |
|
|
131
|
+
| **相量图**<br/> `Domain_Specific_Plots/phasor_diagram_example.py` | 在极坐标上绘制电气工程中的相量图。 | `add_phasor_diagram()` |
|
|
132
|
+
| **分岔图**<br/> `Domain_Specific_Plots/bifurcation_diagram_example.py` | 绘制常用于非线性系统和稳定性分析的分岔图。 | `utils.plot_bifurcation_diagram()` |
|
|
133
|
+
|
|
134
|
+
### 数据分析工具 (Data Analysis Utils)
|
|
135
|
+
|
|
136
|
+
| 示例 | 描述 | 关键功能 |
|
|
137
|
+
| :--- | :--- | :--- |
|
|
138
|
+
| **数据分析工具集**<br/> `Data_Analysis_Utils/data_analysis_utils_example.py` | 演示如何对数据进行分布拟合 (`fit_and_plot_distribution`) 和数据分箱 (`bin_data`)。 | `utils.fit_and_plot_distribution()`, `utils.bin_data()` |
|
|
139
|
+
| **通用工具函数**<br/> `Data_Analysis_Utils/utility_functions_example.py` | 展示更多通用的 `utils` 函数,如在高光谱上高亮特征峰 (`highlight_peaks`) 和在时间序列上标记事件 (`add_event_markers`)。 | `utils.highlight_peaks()`, `utils.add_event_markers()` |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## 贡献
|
|
144
|
+
|
|
145
|
+
欢迎任何形式的贡献!如果你有好的想法、发现了 bug,或者想要添加新的功能,请随时提交 Pull Request 或创建 Issue。
|
|
146
|
+
|
|
147
|
+
## 许可证
|
|
148
|
+
|
|
149
|
+
本项目采用 [MIT License](LICENSE)授权。
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# PaperPlot
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/paperplotter)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
**一个为科研论文设计的声明式 Matplotlib 封装库,让复杂图表的创建变得简单直观。**
|
|
7
|
+
|
|
8
|
+
`PaperPlot` 的诞生是为了解决在准备学术论文时,使用 Matplotlib 创建高质量、布局复杂的图表所面临的繁琐问题。它通过引入声明式的链式 API 和基于标签(tag)的对象管理,让你能够用更少的代码,更清晰的逻辑,构建从简单网格到复杂组合的各类图表。
|
|
9
|
+
|
|
10
|
+
## 核心理念与特性
|
|
11
|
+
|
|
12
|
+
* **🎨 声明式链式调用**: 像写句子一样构建你的图表,例如 `plotter.add_line(...).set_title(...).set_xlabel(...)`。
|
|
13
|
+
* **🏷️ 基于标签的控制**: 给每个子图一个独一无二的 `tag`,之后就可以随时通过 `tag` 对其进行任何修改,告别混乱的 `axes[i][j]` 索引。
|
|
14
|
+
* **🧩 强大的布局系统**: 无论是简单的 `(行, 列)` 网格,还是使用 `subplot_mosaic` 实现的跨行跨列复杂布局,都能轻松定义。
|
|
15
|
+
* **✨ 内置科研主题**: 提供多种专业美观的内置样式,如 `publication`, `presentation` 等,一键切换图表风格。
|
|
16
|
+
* **🔬 丰富的领域专用图表**: 内置了科研中常用的图表类型,如光谱图、混淆矩阵、ROC 曲线、学习曲线、分岔图、相量图等。
|
|
17
|
+
* **🔧 智能美化工具**: `cleanup()` 方法可以智能地共享坐标轴、对齐标签;`cleanup_heatmaps()` 可以为多个热图创建共享的颜色条。
|
|
18
|
+
|
|
19
|
+
## 安装
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install paperplotter
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## 快速开始
|
|
26
|
+
|
|
27
|
+
只需几行代码,就可以创建一个包含两个子图的 1x2 网格图。
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import paperplot as pp
|
|
31
|
+
import pandas as pd
|
|
32
|
+
import numpy as np
|
|
33
|
+
|
|
34
|
+
# 1. 准备数据
|
|
35
|
+
df_line = pd.DataFrame({
|
|
36
|
+
'time': np.linspace(0, 10, 50),
|
|
37
|
+
'signal': np.cos(np.linspace(0, 10, 50))
|
|
38
|
+
})
|
|
39
|
+
df_scatter = pd.DataFrame({
|
|
40
|
+
'x': np.random.rand(50) * 10,
|
|
41
|
+
'y': np.random.rand(50) * 10
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
# 2. 初始化 Plotter 并绘图
|
|
45
|
+
plotter = pp.Plotter(layout=(1, 2), figsize=(10, 4))
|
|
46
|
+
|
|
47
|
+
# 3. 添加图表并使用 tag 标记
|
|
48
|
+
plotter.add_line(data=df_line, x='time', y='signal', tag='time_series')
|
|
49
|
+
plotter.add_scatter(data=df_scatter, x='x', y='y', tag='scatter_plot')
|
|
50
|
+
|
|
51
|
+
# 4. 通过 tag 设置标题和标签
|
|
52
|
+
plotter.set_title('time_series', 'Time Series Data')
|
|
53
|
+
plotter.set_xlabel('time_series', 'Time (s)')
|
|
54
|
+
plotter.set_ylabel('time_series', 'Signal')
|
|
55
|
+
|
|
56
|
+
plotter.set_title('scatter_plot', 'Scatter Plot')
|
|
57
|
+
plotter.set_xlabel('scatter_plot', 'X Value')
|
|
58
|
+
plotter.set_ylabel('scatter_plot', 'Y Value')
|
|
59
|
+
|
|
60
|
+
# 5. 保存图像
|
|
61
|
+
plotter.save("quick_start_figure.png")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## 通过示例学习 (Learn from Examples)
|
|
66
|
+
|
|
67
|
+
掌握 `PaperPlot` 最好的方法就是探索我们提供的丰富示例。每个示例都专注于一个核心功能,并附有详细的代码和注释。
|
|
68
|
+
|
|
69
|
+
### 布局 (Layout)
|
|
70
|
+
|
|
71
|
+
| 示例 | 描述 | 关键功能 |
|
|
72
|
+
| :--- | :--- | :--- |
|
|
73
|
+
| **高级布局**<br/> `Layout/advanced_layout_example.py` | 展示如何使用列表定义一个跨列的复杂布局。 | `layout=[['A', 'B', 'B'], ...]`<br/>`get_ax_by_name()` |
|
|
74
|
+
| **行跨越**<br/> `Layout/row_span_example.py` | 创建一个图表,其中某个子图跨越多行。 | `layout=[['A', 'B'], ['A', 'C']]` |
|
|
75
|
+
| **块跨越**<br/> `Layout/block_span_example.py` | 创建一个图表,其中某个子图同时跨越多行和多列。 | `layout=[['A', 'A', 'B'], ['A', 'A', 'C']]` |
|
|
76
|
+
| **固定子图宽高比**<br/> `Layout/aspect_ratio_example.py` | 在不指定 `figsize` 的情况下,通过 `subplot_aspect` 保证每个子图单元格的宽高比,Plotter 会自动计算画布大小。 | `subplot_aspect=(16, 9)` |
|
|
77
|
+
|
|
78
|
+
### 功能与定制化 (Features & Customization)
|
|
79
|
+
|
|
80
|
+
| 示例 | 描述 | 关键功能 |
|
|
81
|
+
| :--- | :--- | :--- |
|
|
82
|
+
| **多图网格**<br/> `Features_Customization/multi_plot_grid.py` | 在一个网格中混合绘制不同类型的图表(线图、柱状图、散点图、热图)。 | `add_line()`, `add_bar()`, `add_scatter()`, `add_heatmap()` |
|
|
83
|
+
| **高级定制**<br/> `Features_Customization/advanced_customization.py` | 演示如何使用 `get_ax()` "逃生舱口" 来获取原生的 Matplotlib `Axes` 对象,并添加任意 `Patch`(如椭圆)。 | `get_ax()`, `ax.add_patch()` |
|
|
84
|
+
| **全局控制**<br/> `Features_Customization/global_controls_example.py` | 展示如何设置全局标题 (`suptitle`) 和创建全局图例。 | `set_suptitle()`, `add_global_legend()` |
|
|
85
|
+
| **共享颜色条**<br/> `Features_Customization/heatmap_colorbar_example.py` | 为多个热图创建一个共享的、能反映全局数据范围的颜色条。 | `add_heatmap(cbar=False)`, `cleanup_heatmaps()` |
|
|
86
|
+
| **智能清理**<br/> `Features_Customization/cleanup_demonstration.py` | 演示 `cleanup()` 函数如何动态地为指定行/列的子图共享 X/Y 轴,并自动隐藏多余的刻度标签。 | `cleanup(share_y_on_rows=...)`, `cleanup(share_x_on_cols=...)` |
|
|
87
|
+
| **组合图与内嵌图**<br/> `Features_Customization/composite_figure_example.py` | 创建一个 L 型的复杂图表,并在其中一个子图内部嵌入一张图片。 | `layout=[['A', 'A'], ['B', '.']]`, `add_inset_image()` |
|
|
88
|
+
| **功能扩展**<br/> `Features_Customization/feature_expansion_example.py` | 演示双Y轴 (`add_twinx`)、回归图 (`add_regplot`)、参考线 (`add_hline`) 和文本标注 (`add_text`) 等高级功能。 | `add_twinx()`, `add_regplot()`, `add_hline()`, `add_text()` |
|
|
89
|
+
| **错误处理**<br/> `Features_Customization/error_handling_test.py` | 展示 `PaperPlot` 的自定义异常,如 `DuplicateTagError`, `TagNotFoundError`, `PlottingSpaceError`。 | `try...except pp.PaperPlotError` |
|
|
90
|
+
|
|
91
|
+
### 风格与美化 (Styles & Aesthetics)
|
|
92
|
+
|
|
93
|
+
| 示例 | 描述 | 关键功能 |
|
|
94
|
+
| :--- | :--- | :--- |
|
|
95
|
+
| **风格画廊**<br/> `Styles_Aesthetics/style_gallery_example.py` | 循环遍历所有内置的绘图风格,并为每种风格生成一个示例图。 | `Plotter(style='...')` |
|
|
96
|
+
| **统计标注**<br/> `Styles_Aesthetics/statistical_annotation_example.py` | 在箱线图上自动进行多组成对统计检验(如 t-test),并智能堆叠显著性标记。 | `add_box()`, `utils.add_pairwise_tests()` |
|
|
97
|
+
| **美学与处理**<br/> `Styles_Aesthetics/aesthetic_and_processing_example.py` | 使用 `utils` 模块中的函数对数据进行平滑处理或根据条件高亮特定数据点。 | `utils.moving_average()`, `utils.highlight_points()` |
|
|
98
|
+
|
|
99
|
+
### 领域专用图 (Domain-Specific Plots)
|
|
100
|
+
|
|
101
|
+
| 示例 | 描述 | 关键功能 |
|
|
102
|
+
| :--- | :--- | :--- |
|
|
103
|
+
| **领域专用图合集**<br/> `Domain_Specific_Plots/domain_specific_plots_example.py` | 一站式展示多种领域专用图,包括 SERS 光谱图、混淆矩阵、ROC 曲线和 PCA 散点图。 | `add_spectra()`, `add_confusion_matrix()`, `add_roc_curve()`, `add_pca_scatter()` |
|
|
104
|
+
| **学习曲线**<br/> `Domain_Specific_Plots/learning_curve_example.py` | 绘制机器学习模型的学习曲线,帮助诊断过拟合或欠拟合问题。 | `utils.plot_learning_curve()` |
|
|
105
|
+
| **SERS 浓度图**<br/> `Domain_Specific_Plots/concentration_map_example.py` | 绘制 SERS Mapping 浓度图,本质上是带有专业美化的热图。 | `add_concentration_map()` |
|
|
106
|
+
| **电力系统时间序列**<br/> `Domain_Specific_Plots/power_timeseries_example.py` | 绘制电力系统动态仿真结果,并自动标记故障、切除等事件。 | `add_power_timeseries()` |
|
|
107
|
+
| **相量图**<br/> `Domain_Specific_Plots/phasor_diagram_example.py` | 在极坐标上绘制电气工程中的相量图。 | `add_phasor_diagram()` |
|
|
108
|
+
| **分岔图**<br/> `Domain_Specific_Plots/bifurcation_diagram_example.py` | 绘制常用于非线性系统和稳定性分析的分岔图。 | `utils.plot_bifurcation_diagram()` |
|
|
109
|
+
|
|
110
|
+
### 数据分析工具 (Data Analysis Utils)
|
|
111
|
+
|
|
112
|
+
| 示例 | 描述 | 关键功能 |
|
|
113
|
+
| :--- | :--- | :--- |
|
|
114
|
+
| **数据分析工具集**<br/> `Data_Analysis_Utils/data_analysis_utils_example.py` | 演示如何对数据进行分布拟合 (`fit_and_plot_distribution`) 和数据分箱 (`bin_data`)。 | `utils.fit_and_plot_distribution()`, `utils.bin_data()` |
|
|
115
|
+
| **通用工具函数**<br/> `Data_Analysis_Utils/utility_functions_example.py` | 展示更多通用的 `utils` 函数,如在高光谱上高亮特征峰 (`highlight_peaks`) 和在时间序列上标记事件 (`add_event_markers`)。 | `utils.highlight_peaks()`, `utils.add_event_markers()` |
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## 贡献
|
|
120
|
+
|
|
121
|
+
欢迎任何形式的贡献!如果你有好的想法、发现了 bug,或者想要添加新的功能,请随时提交 Pull Request 或创建 Issue。
|
|
122
|
+
|
|
123
|
+
## 许可证
|
|
124
|
+
|
|
125
|
+
本项目采用 [MIT License](LICENSE)授权。
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# styles/flat.mplstyle
|
|
2
|
+
# A modern, flat design style with a bright, friendly palette.
|
|
3
|
+
|
|
4
|
+
# Font (a clean, modern sans-serif)
|
|
5
|
+
font.family : sans-serif
|
|
6
|
+
font.sans-serif : Helvetica, Arial, sans-serif
|
|
7
|
+
font.size : 12
|
|
8
|
+
axes.labelsize : 14
|
|
9
|
+
axes.titlesize : 16
|
|
10
|
+
legend.fontsize : 11
|
|
11
|
+
xtick.labelsize : 10
|
|
12
|
+
ytick.labelsize : 10
|
|
13
|
+
|
|
14
|
+
# Lines
|
|
15
|
+
lines.linewidth : 2.0
|
|
16
|
+
lines.markersize : 6
|
|
17
|
+
|
|
18
|
+
# Axes
|
|
19
|
+
axes.facecolor : "#f0f0f0" # Light gray background for the plot area
|
|
20
|
+
axes.edgecolor : "#b0b0b0"
|
|
21
|
+
axes.labelcolor : "#333333"
|
|
22
|
+
axes.titlecolor : "#333333"
|
|
23
|
+
axes.grid : True
|
|
24
|
+
axes.axisbelow : True
|
|
25
|
+
axes.spines.top : False
|
|
26
|
+
axes.spines.right : False
|
|
27
|
+
|
|
28
|
+
# Ticks
|
|
29
|
+
xtick.color : "#333333"
|
|
30
|
+
ytick.color : "#333333"
|
|
31
|
+
|
|
32
|
+
# Grid
|
|
33
|
+
grid.color : white
|
|
34
|
+
grid.linestyle : -
|
|
35
|
+
|
|
36
|
+
# Figure
|
|
37
|
+
figure.facecolor : white # White background for the figure
|
|
38
|
+
|
|
39
|
+
# Color Cycle (from a flat UI palette)
|
|
40
|
+
axes.prop_cycle: cycler(color=["#3498db", "#2ecc71", "#e74c3c", "#f1c40f", "#9b59b6", "#1abc9c"])
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# styles/nord.mplstyle
|
|
2
|
+
# A cool, arctic, north-bluish color scheme from the Nord palette.
|
|
3
|
+
|
|
4
|
+
# Font
|
|
5
|
+
font.family : sans-serif
|
|
6
|
+
font.sans-serif : Segoe UI, Arial, sans-serif
|
|
7
|
+
font.size : 12
|
|
8
|
+
axes.labelsize : 14
|
|
9
|
+
axes.titlesize : 16
|
|
10
|
+
legend.fontsize : 11
|
|
11
|
+
xtick.labelsize : 10
|
|
12
|
+
ytick.labelsize : 10
|
|
13
|
+
|
|
14
|
+
# Lines
|
|
15
|
+
lines.linewidth : 2.0
|
|
16
|
+
lines.markersize : 6
|
|
17
|
+
|
|
18
|
+
# Axes (light text on dark background)
|
|
19
|
+
axes.facecolor : "#3B4252" # nord1
|
|
20
|
+
axes.edgecolor : "#D8DEE9" # nord4
|
|
21
|
+
axes.labelcolor : "#ECEFF4" # nord6
|
|
22
|
+
axes.titlecolor : "#ECEFF4" # nord6
|
|
23
|
+
axes.grid : True
|
|
24
|
+
axes.axisbelow : True
|
|
25
|
+
axes.spines.top : False
|
|
26
|
+
axes.spines.right : False
|
|
27
|
+
|
|
28
|
+
# Ticks
|
|
29
|
+
xtick.color : "#D8DEE9" # nord4
|
|
30
|
+
ytick.color : "#D8DEE9" # nord4
|
|
31
|
+
|
|
32
|
+
# Grid
|
|
33
|
+
grid.color : "#4C566A" # nord3
|
|
34
|
+
grid.linestyle : --
|
|
35
|
+
|
|
36
|
+
# Figure
|
|
37
|
+
figure.facecolor : "#2E3440" # nord0
|
|
38
|
+
|
|
39
|
+
# Legend
|
|
40
|
+
legend.frameon : False
|
|
41
|
+
legend.labelcolor : "#ECEFF4"
|
|
42
|
+
|
|
43
|
+
# Color Cycle (the "aurora" colors)
|
|
44
|
+
axes.prop_cycle: cycler(color=["#BF616A", "#D08770", "#EBCB8B", "#A3BE8C", "#B48EAD"])
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# styles/presentation.mplstyle
|
|
2
|
+
# 一个适合屏幕演示的、高对比度的深色主题
|
|
3
|
+
|
|
4
|
+
# Fonts (使用无衬线字体,字号更大)
|
|
5
|
+
font.family : sans-serif
|
|
6
|
+
font.sans-serif : Arial, Helvetica, sans-serif
|
|
7
|
+
font.size : 14
|
|
8
|
+
axes.labelsize : 16
|
|
9
|
+
axes.titlesize : 18
|
|
10
|
+
legend.fontsize : 12
|
|
11
|
+
xtick.labelsize : 12
|
|
12
|
+
ytick.labelsize : 12
|
|
13
|
+
|
|
14
|
+
# Lines
|
|
15
|
+
lines.linewidth : 2.5
|
|
16
|
+
lines.markersize : 8
|
|
17
|
+
|
|
18
|
+
# Axes (坐标轴和标签使用白色)
|
|
19
|
+
axes.labelcolor : white
|
|
20
|
+
axes.titlecolor : white
|
|
21
|
+
axes.edgecolor : white
|
|
22
|
+
axes.grid : True
|
|
23
|
+
axes.axisbelow : True
|
|
24
|
+
grid.color : "#444444" # 深灰色网格
|
|
25
|
+
grid.linestyle : -
|
|
26
|
+
|
|
27
|
+
# Ticks (刻度使用白色)
|
|
28
|
+
xtick.color : white
|
|
29
|
+
ytick.color : white
|
|
30
|
+
|
|
31
|
+
# Figure (画布和子图背景设为深色)
|
|
32
|
+
figure.facecolor : "#1e1e1e" # 深灰色背景
|
|
33
|
+
axes.facecolor : "#2a2a2a" # 稍亮的子图背景
|
|
34
|
+
|
|
35
|
+
# Spines (隐藏顶部和右侧的轴线)
|
|
36
|
+
axes.spines.top : False
|
|
37
|
+
axes.spines.right : False
|
|
38
|
+
|
|
39
|
+
# Legend (图例背景透明)
|
|
40
|
+
legend.frameon : False
|
|
41
|
+
legend.labelcolor : white
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Fonts
|
|
2
|
+
font.family : serif
|
|
3
|
+
font.serif : Times New Roman
|
|
4
|
+
font.size : 10
|
|
5
|
+
axes.labelsize : 12
|
|
6
|
+
legend.fontsize : 9
|
|
7
|
+
xtick.labelsize : 8
|
|
8
|
+
ytick.labelsize : 8
|
|
9
|
+
|
|
10
|
+
# Lines
|
|
11
|
+
lines.linewidth : 1.5
|
|
12
|
+
lines.markersize : 4
|
|
13
|
+
|
|
14
|
+
# Axes
|
|
15
|
+
axes.grid : True
|
|
16
|
+
axes.axisbelow : True
|
|
17
|
+
grid.color : 0.8
|
|
18
|
+
grid.linestyle : --
|
|
19
|
+
axes.spines.top : False
|
|
20
|
+
axes.spines.right : False
|
|
21
|
+
|
|
22
|
+
# Figure
|
|
23
|
+
figure.dpi : 300
|
|
24
|
+
figure.facecolor : white
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# styles/solarized_light.mplstyle
|
|
2
|
+
# A light theme based on the popular Solarized palette.
|
|
3
|
+
|
|
4
|
+
# Font
|
|
5
|
+
font.family : sans-serif
|
|
6
|
+
font.sans-serif : Segoe UI, DejaVu Sans, sans-serif
|
|
7
|
+
font.size : 12
|
|
8
|
+
axes.labelsize : 14
|
|
9
|
+
axes.titlesize : 16
|
|
10
|
+
legend.fontsize : 11
|
|
11
|
+
xtick.labelsize : 10
|
|
12
|
+
ytick.labelsize : 10
|
|
13
|
+
|
|
14
|
+
# Lines
|
|
15
|
+
lines.linewidth : 2.0
|
|
16
|
+
lines.markersize : 7
|
|
17
|
+
|
|
18
|
+
# Axes
|
|
19
|
+
axes.facecolor : "#fdf6e3" # base3
|
|
20
|
+
axes.edgecolor : "#93a1a1" # base1
|
|
21
|
+
axes.labelcolor : "#586e75" # base01
|
|
22
|
+
axes.titlecolor : "#073642" # base02
|
|
23
|
+
axes.grid : True
|
|
24
|
+
axes.axisbelow : True
|
|
25
|
+
axes.spines.top : False
|
|
26
|
+
axes.spines.right : False
|
|
27
|
+
|
|
28
|
+
# Ticks
|
|
29
|
+
xtick.color : "#657b83" # base00
|
|
30
|
+
ytick.color : "#657b83" # base00
|
|
31
|
+
|
|
32
|
+
# Grid
|
|
33
|
+
grid.color : "#eee8d5" # base2
|
|
34
|
+
grid.linestyle : -
|
|
35
|
+
|
|
36
|
+
# Figure
|
|
37
|
+
figure.facecolor : "#fdf6e3" # base3
|
|
38
|
+
|
|
39
|
+
# Legend
|
|
40
|
+
legend.framealpha : 0.5
|
|
41
|
+
legend.facecolor : "#eee8d5" # base2
|
|
42
|
+
|
|
43
|
+
# Color Cycle (the accent colors)
|
|
44
|
+
axes.prop_cycle: cycler(color=["#268bd2", "#859900", "#dc322f", "#d33682", "#6c71c4", "#2aa198", "#b58900"])
|