planttrend 0.1.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 planttrend contributors
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,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: planttrend
3
+ Version: 0.1.0
4
+ Summary: Industrial plotting helpers for time-series and process analytics.
5
+ Author: planttrend contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/xiezeyu301/planttrend
8
+ Project-URL: Repository, https://github.com/xiezeyu301/planttrend
9
+ Project-URL: Issues, https://github.com/xiezeyu301/planttrend/issues
10
+ Keywords: plotting,matplotlib,pandas,analytics,visualization
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Scientific/Engineering :: Visualization
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: matplotlib>=3.8
24
+ Requires-Dist: numpy>=1.26
25
+ Requires-Dist: pandas>=2.1
26
+ Provides-Extra: dev
27
+ Requires-Dist: build>=1.2; extra == "dev"
28
+ Requires-Dist: mypy>=1.10; extra == "dev"
29
+ Requires-Dist: pytest>=8; extra == "dev"
30
+ Requires-Dist: pytest-cov>=5; extra == "dev"
31
+ Requires-Dist: ruff>=0.5; extra == "dev"
32
+ Requires-Dist: twine>=5; extra == "dev"
33
+ Dynamic: license-file
34
+
35
+ # planttrend
36
+
37
+ planttrend is a lightweight plotting helper library built on top of pandas and matplotlib. It is aimed at industrial process data analysis, time-series trend comparison, correlation inspection, and label/style reuse.
38
+
39
+ ## Features
40
+
41
+ - Multi-axis trend plotting for process variables
42
+ - Correlation heatmaps for numeric columns
43
+ - Distribution comparison charts
44
+ - Reusable tag metadata for equipment tags, aliases, units, remarks, and industrial variable types
45
+ - Built-in style presets for dashboards, reports, and industrial scenes
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pip install planttrend
51
+ ```
52
+
53
+ ## Quick start
54
+
55
+ ```python
56
+ import pandas as pd
57
+ from planttrend import plot_columns, plot_correlation_heatmap, plot_distribution
58
+
59
+ frame = pd.read_csv("example.csv")
60
+
61
+ plot_columns(
62
+ frame,
63
+ columns=[["TE301101H.AI1.PV"], ["LT301101H.AI1.PV", "FT301101H.AI1.PV"]],
64
+ x="时间",
65
+ style="industrial",
66
+ )
67
+
68
+ plot_correlation_heatmap(frame)
69
+ plot_distribution(frame, columns=["FT301101H.AI1.PV", "FT301103H.AI1.PV"])
70
+ ```
71
+
72
+ ## Class-based usage
73
+
74
+ If you want to reuse a default plotting config across multiple charts, use the `PlantTrend` client:
75
+
76
+ ```python
77
+ import pandas as pd
78
+ from planttrend import PlantTrend
79
+
80
+ frame = pd.read_csv("example.csv")
81
+
82
+ plotter = PlantTrend(
83
+ config={
84
+ "style": "industrial",
85
+ "show": False,
86
+ "show_type_badges": True,
87
+ "map_dict": {
88
+ "FT301101H.AI1.PV": {
89
+ "des": "进料流量",
90
+ "unit": "t/h",
91
+ "remark": "主进料流量",
92
+ "type": "观测量",
93
+ },
94
+ "LT301101H.AI1.PV": {
95
+ "des": "液位",
96
+ "unit": "m",
97
+ "remark": "罐液位",
98
+ "type": "控制量",
99
+ },
100
+ },
101
+ }
102
+ )
103
+
104
+ plotter.plot_columns(
105
+ frame,
106
+ columns=[
107
+ ["FT301101H.AI1.PV"],
108
+ [["LT301101H.AI1.PV"], ["FT301103H.AI1.PV"]],
109
+ ],
110
+ x="时间",
111
+ )
112
+
113
+ plotter.plot_distribution(
114
+ frame,
115
+ columns=["FT301101H.AI1.PV", "FT301103H.AI1.PV"],
116
+ )
117
+
118
+ plotter.plot_correlation_heatmap(frame)
119
+ ```
120
+
121
+ `PlantTrend` also exposes `get_config()`, `update_config()`, `reset_config()`, `clone()`, and `describe_config()` for managing shared plotting settings.
122
+
123
+ You can also create a plotter from a tag metadata CSV with columns `tag`, `des`, `unit`, `remark`, and optional `type`:
124
+
125
+ ```csv
126
+ tag,des,unit,remark,type
127
+ FT301101H.AI1.PV,进料流量,t/h,主进料流量,观测量
128
+ LT301101H.AI1.PV,液位,m,罐液位,控制量
129
+ ```
130
+
131
+ ```python
132
+ plotter = PlantTrend.from_tag_meta_csv(
133
+ "tag-meta.csv",
134
+ encoding="utf-8",
135
+ config={"style": "industrial", "show": False},
136
+ )
137
+ ```
138
+
139
+ For `plot_columns`, metadata labels are rendered as `des(unit)`, for example `进料流量(t/h)`.
140
+ If `type` is provided, each subplot draws rounded type badges just outside the upper-right plot border, with the badge bottom attached to the border line. Supported industrial values are commonly `控制量` and `观测量`; if one subplot contains multiple curves, their type badges are laid out horizontally near the right border next to each other and without exceeding the plot frame horizontally.
141
+ Set `config={"show_type_badges": False}` to hide these type badges globally for `plot_columns`.
142
+
143
+ If your metadata CSV uses Chinese column names, pass column mappings explicitly:
144
+
145
+ ```python
146
+ plotter = PlantTrend.from_tag_meta_csv(
147
+ "tag_meta.csv",
148
+ encoding="gbk",
149
+ config={"style": "industrial"},
150
+ tag_col="位号",
151
+ des_col="注释",
152
+ unit_col="单位",
153
+ remark_col="备注",
154
+ type_col="类型",
155
+ )
156
+ ```
157
+
158
+ ## Style preview
159
+
160
+ ![planttrend style preview](docs/style-preview.png)
161
+
162
+ Regenerate the preview image with:
163
+
164
+ ```bash
165
+ python tests/render_style_preview.py
166
+ ```
167
+
168
+ ## Development
169
+
170
+ ```bash
171
+ python -m pip install -e .[dev]
172
+ python -m unittest discover -s tests -v
173
+ python -m ruff check src tests
174
+ python -m mypy
175
+ python -m build
176
+ ```
177
+
178
+ The generated artifacts will be placed in the `dist` directory. Use `python -m twine check dist/*` before publishing packages manually.
179
+
180
+ ## GitHub Actions release
181
+
182
+ This repository includes an automated publish workflow at .github/workflows/publish.yml.
183
+
184
+ Before using it:
185
+
186
+ 1. Create a PyPI API token.
187
+ 2. In GitHub, open Settings > Secrets and variables > Actions.
188
+ 3. Add a repository secret named PYPI_API_TOKEN.
189
+ 4. Keep the version in pyproject.toml aligned with the Git tag you plan to push.
190
+
191
+ ### Automatic publish by tag
192
+
193
+ Update the package version first, then push a tag in the form v0.1.0:
194
+
195
+ ```bash
196
+ git tag v0.1.0
197
+ git push origin v0.1.0
198
+ ```
199
+
200
+ The workflow will run tests, build the package, validate the artifacts, and upload them to PyPI.
201
+
202
+ ### Manual run from GitHub
203
+
204
+ You can also run the workflow from the Actions tab with workflow_dispatch.
205
+ If you leave publish_to_pypi unchecked, it only runs test and build validation.
206
+ If you check publish_to_pypi, it will also upload dist artifacts to PyPI.
207
+
208
+ ## License
209
+
210
+ planttrend is released under the MIT License. See the `LICENSE` file for details.
@@ -0,0 +1,176 @@
1
+ # planttrend
2
+
3
+ planttrend is a lightweight plotting helper library built on top of pandas and matplotlib. It is aimed at industrial process data analysis, time-series trend comparison, correlation inspection, and label/style reuse.
4
+
5
+ ## Features
6
+
7
+ - Multi-axis trend plotting for process variables
8
+ - Correlation heatmaps for numeric columns
9
+ - Distribution comparison charts
10
+ - Reusable tag metadata for equipment tags, aliases, units, remarks, and industrial variable types
11
+ - Built-in style presets for dashboards, reports, and industrial scenes
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pip install planttrend
17
+ ```
18
+
19
+ ## Quick start
20
+
21
+ ```python
22
+ import pandas as pd
23
+ from planttrend import plot_columns, plot_correlation_heatmap, plot_distribution
24
+
25
+ frame = pd.read_csv("example.csv")
26
+
27
+ plot_columns(
28
+ frame,
29
+ columns=[["TE301101H.AI1.PV"], ["LT301101H.AI1.PV", "FT301101H.AI1.PV"]],
30
+ x="时间",
31
+ style="industrial",
32
+ )
33
+
34
+ plot_correlation_heatmap(frame)
35
+ plot_distribution(frame, columns=["FT301101H.AI1.PV", "FT301103H.AI1.PV"])
36
+ ```
37
+
38
+ ## Class-based usage
39
+
40
+ If you want to reuse a default plotting config across multiple charts, use the `PlantTrend` client:
41
+
42
+ ```python
43
+ import pandas as pd
44
+ from planttrend import PlantTrend
45
+
46
+ frame = pd.read_csv("example.csv")
47
+
48
+ plotter = PlantTrend(
49
+ config={
50
+ "style": "industrial",
51
+ "show": False,
52
+ "show_type_badges": True,
53
+ "map_dict": {
54
+ "FT301101H.AI1.PV": {
55
+ "des": "进料流量",
56
+ "unit": "t/h",
57
+ "remark": "主进料流量",
58
+ "type": "观测量",
59
+ },
60
+ "LT301101H.AI1.PV": {
61
+ "des": "液位",
62
+ "unit": "m",
63
+ "remark": "罐液位",
64
+ "type": "控制量",
65
+ },
66
+ },
67
+ }
68
+ )
69
+
70
+ plotter.plot_columns(
71
+ frame,
72
+ columns=[
73
+ ["FT301101H.AI1.PV"],
74
+ [["LT301101H.AI1.PV"], ["FT301103H.AI1.PV"]],
75
+ ],
76
+ x="时间",
77
+ )
78
+
79
+ plotter.plot_distribution(
80
+ frame,
81
+ columns=["FT301101H.AI1.PV", "FT301103H.AI1.PV"],
82
+ )
83
+
84
+ plotter.plot_correlation_heatmap(frame)
85
+ ```
86
+
87
+ `PlantTrend` also exposes `get_config()`, `update_config()`, `reset_config()`, `clone()`, and `describe_config()` for managing shared plotting settings.
88
+
89
+ You can also create a plotter from a tag metadata CSV with columns `tag`, `des`, `unit`, `remark`, and optional `type`:
90
+
91
+ ```csv
92
+ tag,des,unit,remark,type
93
+ FT301101H.AI1.PV,进料流量,t/h,主进料流量,观测量
94
+ LT301101H.AI1.PV,液位,m,罐液位,控制量
95
+ ```
96
+
97
+ ```python
98
+ plotter = PlantTrend.from_tag_meta_csv(
99
+ "tag-meta.csv",
100
+ encoding="utf-8",
101
+ config={"style": "industrial", "show": False},
102
+ )
103
+ ```
104
+
105
+ For `plot_columns`, metadata labels are rendered as `des(unit)`, for example `进料流量(t/h)`.
106
+ If `type` is provided, each subplot draws rounded type badges just outside the upper-right plot border, with the badge bottom attached to the border line. Supported industrial values are commonly `控制量` and `观测量`; if one subplot contains multiple curves, their type badges are laid out horizontally near the right border next to each other and without exceeding the plot frame horizontally.
107
+ Set `config={"show_type_badges": False}` to hide these type badges globally for `plot_columns`.
108
+
109
+ If your metadata CSV uses Chinese column names, pass column mappings explicitly:
110
+
111
+ ```python
112
+ plotter = PlantTrend.from_tag_meta_csv(
113
+ "tag_meta.csv",
114
+ encoding="gbk",
115
+ config={"style": "industrial"},
116
+ tag_col="位号",
117
+ des_col="注释",
118
+ unit_col="单位",
119
+ remark_col="备注",
120
+ type_col="类型",
121
+ )
122
+ ```
123
+
124
+ ## Style preview
125
+
126
+ ![planttrend style preview](docs/style-preview.png)
127
+
128
+ Regenerate the preview image with:
129
+
130
+ ```bash
131
+ python tests/render_style_preview.py
132
+ ```
133
+
134
+ ## Development
135
+
136
+ ```bash
137
+ python -m pip install -e .[dev]
138
+ python -m unittest discover -s tests -v
139
+ python -m ruff check src tests
140
+ python -m mypy
141
+ python -m build
142
+ ```
143
+
144
+ The generated artifacts will be placed in the `dist` directory. Use `python -m twine check dist/*` before publishing packages manually.
145
+
146
+ ## GitHub Actions release
147
+
148
+ This repository includes an automated publish workflow at .github/workflows/publish.yml.
149
+
150
+ Before using it:
151
+
152
+ 1. Create a PyPI API token.
153
+ 2. In GitHub, open Settings > Secrets and variables > Actions.
154
+ 3. Add a repository secret named PYPI_API_TOKEN.
155
+ 4. Keep the version in pyproject.toml aligned with the Git tag you plan to push.
156
+
157
+ ### Automatic publish by tag
158
+
159
+ Update the package version first, then push a tag in the form v0.1.0:
160
+
161
+ ```bash
162
+ git tag v0.1.0
163
+ git push origin v0.1.0
164
+ ```
165
+
166
+ The workflow will run tests, build the package, validate the artifacts, and upload them to PyPI.
167
+
168
+ ### Manual run from GitHub
169
+
170
+ You can also run the workflow from the Actions tab with workflow_dispatch.
171
+ If you leave publish_to_pypi unchecked, it only runs test and build validation.
172
+ If you check publish_to_pypi, it will also upload dist artifacts to PyPI.
173
+
174
+ ## License
175
+
176
+ planttrend is released under the MIT License. See the `LICENSE` file for details.
@@ -0,0 +1,77 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "planttrend"
7
+ version = "0.1.0"
8
+ description = "Industrial plotting helpers for time-series and process analytics."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [
14
+ {name = "planttrend contributors"},
15
+ ]
16
+ dependencies = [
17
+ "matplotlib>=3.8",
18
+ "numpy>=1.26",
19
+ "pandas>=2.1",
20
+ ]
21
+ keywords = ["plotting", "matplotlib", "pandas", "analytics", "visualization"]
22
+ classifiers = [
23
+ "Development Status :: 3 - Alpha",
24
+ "Intended Audience :: Developers",
25
+ "Intended Audience :: Science/Research",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.9",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Topic :: Scientific/Engineering :: Visualization",
32
+ ]
33
+
34
+ [project.optional-dependencies]
35
+ dev = [
36
+ "build>=1.2",
37
+ "mypy>=1.10",
38
+ "pytest>=8",
39
+ "pytest-cov>=5",
40
+ "ruff>=0.5",
41
+ "twine>=5",
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://github.com/xiezeyu301/planttrend"
46
+ Repository = "https://github.com/xiezeyu301/planttrend"
47
+ Issues = "https://github.com/xiezeyu301/planttrend/issues"
48
+
49
+ [tool.setuptools]
50
+ package-dir = {"" = "src"}
51
+ include-package-data = true
52
+
53
+ [tool.setuptools.packages.find]
54
+ where = ["src"]
55
+
56
+ [tool.setuptools.package-data]
57
+ planttrend = ["py.typed"]
58
+
59
+ [tool.pytest.ini_options]
60
+ testpaths = ["tests"]
61
+ pythonpath = ["src"]
62
+
63
+ [tool.ruff]
64
+ line-length = 120
65
+ target-version = "py39"
66
+ src = ["src", "tests"]
67
+
68
+ [tool.ruff.lint]
69
+ select = ["E", "F", "I", "UP", "B", "SIM"]
70
+ ignore = ["E501"]
71
+
72
+ [tool.mypy]
73
+ python_version = "3.9"
74
+ files = ["src/planttrend"]
75
+ ignore_missing_imports = true
76
+ warn_unused_ignores = true
77
+ warn_redundant_casts = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,22 @@
1
+ from .analytics import plot_correlation_heatmap, plot_distribution
2
+ from .client import PlantTrend
3
+ from .columns import plot_columns
4
+ from .config_info import describe_plot_config
5
+ from .labels import get_default_label_map, load_label_map, load_tag_meta_map, merge_label_maps
6
+ from .styles import apply_plot_style, get_available_styles
7
+
8
+ __version__ = '0.1.0'
9
+
10
+ __all__ = [
11
+ 'apply_plot_style',
12
+ 'PlantTrend',
13
+ 'describe_plot_config',
14
+ 'get_default_label_map',
15
+ 'get_available_styles',
16
+ 'load_label_map',
17
+ 'load_tag_meta_map',
18
+ 'merge_label_maps',
19
+ 'plot_columns',
20
+ 'plot_correlation_heatmap',
21
+ 'plot_distribution',
22
+ ]