scienceplots-toolkit 0.1.1__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.
- scienceplots_toolkit-0.1.1/.agents/skills/scienceplots-viz/SKILL.md +206 -0
- scienceplots_toolkit-0.1.1/.envrc +12 -0
- scienceplots_toolkit-0.1.1/.gitignore +73 -0
- scienceplots_toolkit-0.1.1/.python-version +1 -0
- scienceplots_toolkit-0.1.1/AGENTS.md +41 -0
- scienceplots_toolkit-0.1.1/CHANGELOG.md +72 -0
- scienceplots_toolkit-0.1.1/LICENSE +31 -0
- scienceplots_toolkit-0.1.1/PKG-INFO +260 -0
- scienceplots_toolkit-0.1.1/PYPI_SETUP_WITH_AGENIX.md +154 -0
- scienceplots_toolkit-0.1.1/QUICK_START.md +182 -0
- scienceplots_toolkit-0.1.1/README.md +224 -0
- scienceplots_toolkit-0.1.1/RELEASE.md +429 -0
- scienceplots_toolkit-0.1.1/devenv.lock +1206 -0
- scienceplots_toolkit-0.1.1/devenv.nix +19 -0
- scienceplots_toolkit-0.1.1/devenv.yaml +11 -0
- scienceplots_toolkit-0.1.1/examples/example_basic.py +221 -0
- scienceplots_toolkit-0.1.1/pyproject.toml +88 -0
- scienceplots_toolkit-0.1.1/scripts/load-pypi-tokens.sh +66 -0
- scienceplots_toolkit-0.1.1/scripts/mirror-to-github.sh +96 -0
- scienceplots_toolkit-0.1.1/scripts/release.sh +343 -0
- scienceplots_toolkit-0.1.1/scripts/test-testpypi-install.sh +276 -0
- scienceplots_toolkit-0.1.1/src/scienceplots_toolkit/__init__.py +54 -0
- scienceplots_toolkit-0.1.1/src/scienceplots_toolkit/analysis.py +70 -0
- scienceplots_toolkit-0.1.1/src/scienceplots_toolkit/style.py +139 -0
- scienceplots_toolkit-0.1.1/src/scienceplots_toolkit/utils.py +98 -0
- scienceplots_toolkit-0.1.1/tests/__init__.py +1 -0
- scienceplots_toolkit-0.1.1/tests/test_analysis.py +140 -0
- scienceplots_toolkit-0.1.1/tests/test_style.py +93 -0
- scienceplots_toolkit-0.1.1/tests/test_utils.py +173 -0
- scienceplots_toolkit-0.1.1/uv.lock +1259 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scienceplots-viz
|
|
3
|
+
description: How to create scientific visualizations with SciencePlots and LaTeX. Use this skill whenever the user wants to create publication-quality plots, scientific figures, data visualizations with matplotlib, or needs to follow the project's strict plotting standards. This includes 24h load profiles, energy visualizations, quantile shading, statistical annotations, or any matplotlib plotting in this repository. Also use this skill for any Python coding tasks in this project - it contains all the coding standards, path handling requirements, and implementation workflows. Make sure to use this skill even if the user doesn't explicitly mention "SciencePlots" - if they're asking for plots, charts, figures, or Python scripts in this project, trigger this skill.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# SciencePlots Visualization
|
|
7
|
+
|
|
8
|
+
A skill for creating publication-quality scientific visualizations using Matplotlib with SciencePlots styles and LaTeX typesetting, and for implementing Python scripts following project standards.
|
|
9
|
+
|
|
10
|
+
## Domain
|
|
11
|
+
|
|
12
|
+
Data visualization, scientific plotting, Python implementation
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
Use this skill whenever:
|
|
17
|
+
|
|
18
|
+
- Creating any matplotlib plot, chart, or figure
|
|
19
|
+
- Working with scientific data visualization
|
|
20
|
+
- Needing publication-quality plots with LaTeX typesetting
|
|
21
|
+
- Creating 24h time-series profiles (energy load curves, daily patterns)
|
|
22
|
+
- Adding statistical annotations (average, peak values)
|
|
23
|
+
- Visualizing uncertainty with quantile shading
|
|
24
|
+
- Following the project's plotting standards
|
|
25
|
+
- **Writing any Python code in this repository**
|
|
26
|
+
- **Creating or modifying scripts**
|
|
27
|
+
- **Implementing data processing or analysis**
|
|
28
|
+
|
|
29
|
+
## Core Mandates
|
|
30
|
+
|
|
31
|
+
These are absolute requirements that MUST be followed in all implementations:
|
|
32
|
+
|
|
33
|
+
### Path Handling
|
|
34
|
+
|
|
35
|
+
ALWAYS use `pathlib.Path` for all path operations. Scripts MUST work from any execution directory.
|
|
36
|
+
|
|
37
|
+
**NEVER use:**
|
|
38
|
+
|
|
39
|
+
- `os.chdir()` - changing directory is forbidden
|
|
40
|
+
- `sys.path.insert()` - manipulating import paths is forbidden
|
|
41
|
+
- String concatenation for paths (e.g., `dir + "/" + file`)
|
|
42
|
+
|
|
43
|
+
**ALWAYS use:**
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from pathlib import Path
|
|
47
|
+
|
|
48
|
+
# Correct - works from any directory
|
|
49
|
+
OUTPUT_DIR = Path("output")
|
|
50
|
+
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
|
51
|
+
|
|
52
|
+
# Correct - relative to script location
|
|
53
|
+
SCRIPT_DIR = Path(__file__).parent
|
|
54
|
+
DATA_DIR = SCRIPT_DIR / "data"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Plotting Excellence
|
|
58
|
+
|
|
59
|
+
Adhere strictly to the Matplotlib Object-Oriented API and the project's custom styling:
|
|
60
|
+
|
|
61
|
+
- **ALWAYS** use `fig, ax = plt.subplots()` instead of `plt.plot()`
|
|
62
|
+
- **ALWAYS** call `configure_matplotlib_style()` at the start
|
|
63
|
+
- **ALWAYS** use professional LaTeX typesetting for labels
|
|
64
|
+
- **ALWAYS** save plots using `save_plot(fig, filename)`
|
|
65
|
+
|
|
66
|
+
### Reliability
|
|
67
|
+
|
|
68
|
+
All findings MUST be reproducible via permanent, executable scripts:
|
|
69
|
+
|
|
70
|
+
- No interactive-only code
|
|
71
|
+
- All scripts must be runnable from command line
|
|
72
|
+
- Include `if __name__ == "__main__":` blocks
|
|
73
|
+
- Document dependencies and usage
|
|
74
|
+
|
|
75
|
+
## Implementation Workflow
|
|
76
|
+
|
|
77
|
+
### 1. Check Existing Utilities
|
|
78
|
+
|
|
79
|
+
Before implementing custom logic, check:
|
|
80
|
+
|
|
81
|
+
- `src/scienceplots_toolkit/utils.py` - Common plotting helpers
|
|
82
|
+
- `src/scienceplots_toolkit/analysis.py` - Advanced analysis tools
|
|
83
|
+
|
|
84
|
+
Common utilities:
|
|
85
|
+
|
|
86
|
+
- `save_plot(fig, filename)` - Save to PNG and PDF
|
|
87
|
+
- `configure_24h_axis(ax)` - Set up 0-24h x-axis
|
|
88
|
+
- `add_stats_box(ax, avg, peak)` - Add statistical annotations
|
|
89
|
+
- `plot_profile_with_quantiles(ax, x, mean, q10, q90)` - Uncertainty shading
|
|
90
|
+
- `generate_profile_grid(n_rows, n_cols)` - Multi-panel layouts
|
|
91
|
+
|
|
92
|
+
### 2. Setup
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
import matplotlib.pyplot as plt
|
|
96
|
+
import numpy as np
|
|
97
|
+
from scienceplots_toolkit import configure_matplotlib_style, save_plot
|
|
98
|
+
from scienceplots_toolkit.utils import configure_24h_axis, add_stats_box
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 3. Implementation Standards
|
|
102
|
+
|
|
103
|
+
- **Type hints**: Use modern type hints (`list[str]`, `tuple[float, ...]`)
|
|
104
|
+
- **Strings**: Use f-strings for formatting
|
|
105
|
+
- **Spelling**: Use English in docstrings
|
|
106
|
+
- **Docstrings**: Include Args sections for all functions
|
|
107
|
+
- **LaTeX labels**: Use raw strings: `r"$\sin(x)$"`, `r"Power (kW)"`
|
|
108
|
+
|
|
109
|
+
### 4. Plotting Guidelines
|
|
110
|
+
|
|
111
|
+
- **LaTeX typesetting**: Professional math mode for all labels and units
|
|
112
|
+
- **Constrained layout**: Active by default (don't disable)
|
|
113
|
+
- **Saving**: Always save both PNG and PDF formats
|
|
114
|
+
- **Cleanup**: Always call `plt.close(fig)` after saving
|
|
115
|
+
- **24h profiles**: Use `configure_24h_axis(ax)` for daily time series
|
|
116
|
+
- **Statistics**: Use `add_stats_box()` for average/peak annotations
|
|
117
|
+
- **Uncertainty**: Use `plot_profile_with_quantiles()` for shaded regions
|
|
118
|
+
|
|
119
|
+
### 5. Verification
|
|
120
|
+
|
|
121
|
+
After implementation:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Linting
|
|
125
|
+
uv run ruff check .
|
|
126
|
+
|
|
127
|
+
# Formatting
|
|
128
|
+
uv run ruff format .
|
|
129
|
+
|
|
130
|
+
# Type checking
|
|
131
|
+
uv run ty check .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Example
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
"""Generate a 24h load profile with uncertainty shading."""
|
|
138
|
+
|
|
139
|
+
from pathlib import Path
|
|
140
|
+
import matplotlib.pyplot as plt
|
|
141
|
+
import numpy as np
|
|
142
|
+
from scienceplots_toolkit import configure_matplotlib_style, save_plot
|
|
143
|
+
from scienceplots_toolkit.utils import configure_24h_axis, add_stats_box
|
|
144
|
+
from scienceplots_toolkit.analysis import plot_profile_with_quantiles
|
|
145
|
+
|
|
146
|
+
def main() -> None:
|
|
147
|
+
"""Generate example 24h load profile."""
|
|
148
|
+
configure_matplotlib_style(use_latex=True)
|
|
149
|
+
|
|
150
|
+
# Generate mock data
|
|
151
|
+
x = np.arange(24)
|
|
152
|
+
mean = 5 + 3 * np.exp(-((x - 19) ** 2) / 20)
|
|
153
|
+
q10 = mean * 0.8
|
|
154
|
+
q90 = mean * 1.2
|
|
155
|
+
|
|
156
|
+
# Create plot
|
|
157
|
+
fig, ax = plt.subplots(figsize=(10, 6))
|
|
158
|
+
plot_profile_with_quantiles(
|
|
159
|
+
ax, x, mean, q10, q90,
|
|
160
|
+
label="Load Profile",
|
|
161
|
+
color="C0"
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
configure_24h_axis(ax)
|
|
165
|
+
add_stats_box(ax, avg=mean.mean(), peak=mean.max(), unit=r"\text{kW}")
|
|
166
|
+
|
|
167
|
+
ax.set_xlabel(r"Time of Day (h)")
|
|
168
|
+
ax.set_ylabel(r"Power Consumption (kW)")
|
|
169
|
+
ax.legend()
|
|
170
|
+
|
|
171
|
+
# Save and cleanup
|
|
172
|
+
save_plot(fig, "load_profile")
|
|
173
|
+
plt.close(fig)
|
|
174
|
+
|
|
175
|
+
if __name__ == "__main__":
|
|
176
|
+
main()
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Quality Checklist
|
|
180
|
+
|
|
181
|
+
Before considering a visualization or script complete:
|
|
182
|
+
|
|
183
|
+
- [ ] English spelling in docstrings
|
|
184
|
+
- [ ] Matplotlib Object-Oriented API used (`fig, ax = plt.subplots()`)
|
|
185
|
+
- [ ] `configure_matplotlib_style()` called at start
|
|
186
|
+
- [ ] LaTeX math mode for labels and units
|
|
187
|
+
- [ ] Both PNG and PDF formats saved
|
|
188
|
+
- [ ] `plt.close(fig)` called after saving
|
|
189
|
+
- [ ] Type hints present on all functions
|
|
190
|
+
- [ ] Docstrings with Args sections
|
|
191
|
+
- [ ] Script works from any execution directory
|
|
192
|
+
|
|
193
|
+
## Bundled Resources
|
|
194
|
+
|
|
195
|
+
- `scripts/` - Executable utilities for common tasks
|
|
196
|
+
- `references/` - Documentation on matplotlib best practices, coding standards
|
|
197
|
+
- `assets/` - Templates and style configurations
|
|
198
|
+
|
|
199
|
+
## Related Files
|
|
200
|
+
|
|
201
|
+
- `src/scienceplots_toolkit/style.py` - Style configuration
|
|
202
|
+
- `src/scienceplots_toolkit/utils.py` - Utility functions
|
|
203
|
+
- `src/scienceplots_toolkit/analysis.py` - Analysis tools
|
|
204
|
+
- `examples/` - Working example scripts
|
|
205
|
+
- `PUBLICATION_PLAN.md` - PyPI publication workflow
|
|
206
|
+
- `CHANGELOG.md` - Version history
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
export DIRENV_WARN_TIMEOUT=20s
|
|
4
|
+
|
|
5
|
+
eval "$(devenv direnvrc)"
|
|
6
|
+
|
|
7
|
+
# `use devenv` supports the same options as the `devenv shell` command.
|
|
8
|
+
#
|
|
9
|
+
# To silence all output, use `--quiet`.
|
|
10
|
+
#
|
|
11
|
+
# Example usage: use devenv --quiet --impure --option services.postgres.enable:bool true
|
|
12
|
+
use devenv
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Virtual environments
|
|
2
|
+
.venv/
|
|
3
|
+
venv/
|
|
4
|
+
env/
|
|
5
|
+
ENV/
|
|
6
|
+
|
|
7
|
+
# Python cache and compiled files
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*$py.class
|
|
11
|
+
|
|
12
|
+
# Test and coverage
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.coverage
|
|
15
|
+
.coverage.*
|
|
16
|
+
htmlcov/
|
|
17
|
+
nosetests.xml
|
|
18
|
+
coverage.xml
|
|
19
|
+
|
|
20
|
+
# mypy / ruff / other tool caches
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
.ruff_cache/
|
|
23
|
+
|
|
24
|
+
# Build / packaging
|
|
25
|
+
build/
|
|
26
|
+
dist/
|
|
27
|
+
*.egg-info/
|
|
28
|
+
# Logs and runtime files
|
|
29
|
+
*.log
|
|
30
|
+
analysis.log
|
|
31
|
+
|
|
32
|
+
# Output artifacts (generated by the examples / container)
|
|
33
|
+
output/
|
|
34
|
+
*.png
|
|
35
|
+
*.pdf
|
|
36
|
+
|
|
37
|
+
# Old redundant files (cleanup)
|
|
38
|
+
example.py
|
|
39
|
+
example_energy.py
|
|
40
|
+
MatplotlibStyle.py
|
|
41
|
+
plotting_utils.py
|
|
42
|
+
profile_analysis.py
|
|
43
|
+
requirements.txt
|
|
44
|
+
# Editor / OS files
|
|
45
|
+
.vscode/
|
|
46
|
+
.idea/
|
|
47
|
+
*.swp
|
|
48
|
+
.DS_Store
|
|
49
|
+
Thumbs.db
|
|
50
|
+
|
|
51
|
+
# Sensitive files (if you add them)
|
|
52
|
+
.env
|
|
53
|
+
.env.*
|
|
54
|
+
|
|
55
|
+
# Devenv
|
|
56
|
+
.devenv*
|
|
57
|
+
devenv.local.nix
|
|
58
|
+
devenv.local.yaml
|
|
59
|
+
.flake.nix.swp
|
|
60
|
+
*swp
|
|
61
|
+
|
|
62
|
+
# direnv
|
|
63
|
+
.direnv
|
|
64
|
+
|
|
65
|
+
# pre-commit
|
|
66
|
+
# pre-commit
|
|
67
|
+
.pre-commit-config.yaml
|
|
68
|
+
|
|
69
|
+
# devenv null directory (temporary interpreter issue)
|
|
70
|
+
null/
|
|
71
|
+
|
|
72
|
+
# AI agent session data
|
|
73
|
+
.sisyphus/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# AI Agent Mandates
|
|
2
|
+
|
|
3
|
+
This repository uses a specialized skill for all Python development and data visualization work.
|
|
4
|
+
|
|
5
|
+
## Primary Skill
|
|
6
|
+
|
|
7
|
+
**ALWAYS use the [scienceplots-viz](.agents/skills/scienceplots-viz/SKILL.md) skill for:**
|
|
8
|
+
|
|
9
|
+
- Any Python coding tasks
|
|
10
|
+
- Creating or modifying scripts
|
|
11
|
+
- Data visualization and plotting
|
|
12
|
+
- Implementation workflows
|
|
13
|
+
- Coding standards and best practices
|
|
14
|
+
|
|
15
|
+
The skill contains comprehensive instructions for:
|
|
16
|
+
|
|
17
|
+
- Path handling requirements
|
|
18
|
+
- Plotting standards
|
|
19
|
+
- Implementation workflows
|
|
20
|
+
- Verification procedures
|
|
21
|
+
|
|
22
|
+
## How to Use
|
|
23
|
+
|
|
24
|
+
1. **Trigger the skill** - It will automatically activate when you work on Python files or plotting tasks
|
|
25
|
+
2. **Follow the skill instructions** - All coding and plotting standards are documented there
|
|
26
|
+
3. **Use bundled resources** - Check `references/` for additional documentation
|
|
27
|
+
|
|
28
|
+
## Project Context
|
|
29
|
+
|
|
30
|
+
- **Package**: `scienceplots_toolkit` - Publication-quality Matplotlib utilities
|
|
31
|
+
- **Source**: `src/scienceplots_toolkit/`
|
|
32
|
+
- **Examples**: `examples/`
|
|
33
|
+
- **Documentation**: `README.md`, `PUBLICATION_PLAN.md`
|
|
34
|
+
|
|
35
|
+
## Questions?
|
|
36
|
+
|
|
37
|
+
Refer to:
|
|
38
|
+
|
|
39
|
+
- [scienceplots-viz Skill](.agents/skills/scienceplots-viz/SKILL.md) - Complete implementation guide
|
|
40
|
+
- [README.md](README.md) - Project overview
|
|
41
|
+
- [PUBLICATION_PLAN.md](PUBLICATION_PLAN.md) - Publication workflow
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-05-07
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Initial release** of scienceplots-toolkit v0.1.0
|
|
13
|
+
- **Style configuration** - `configure_matplotlib_style()` with SciencePlots integration
|
|
14
|
+
- **Utility functions**:
|
|
15
|
+
- `save_plot()` - Save figures to PNG and PDF with logging
|
|
16
|
+
- `configure_24h_axis()` - Standard 24-hour time axis configuration
|
|
17
|
+
- `add_stats_box()` - Statistical annotation boxes for average/peak values
|
|
18
|
+
- **Analysis tools**:
|
|
19
|
+
- `plot_profile_with_quantiles()` - Plot mean with shaded 10%-90% quantiles
|
|
20
|
+
- `generate_profile_grid()` - Multi-panel grid generation for comparative plots
|
|
21
|
+
- **Colormap utilities** - `qual_cmap()` for qualitative color schemes
|
|
22
|
+
- **Comprehensive test suite** - 36 unit tests covering all public functions
|
|
23
|
+
- **Example scripts** - Basic plots and energy profile examples with CLI interface
|
|
24
|
+
- **Documentation** - Complete README with API reference, installation guide, and examples
|
|
25
|
+
- **Development tooling** - Pre-commit hooks, ruff, ty, pytest configuration
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **Logging** - Replaced `print()` statements with proper logging in `save_plot()`
|
|
30
|
+
- **API** - Added optional `output_dir` parameter to `save_plot()` function
|
|
31
|
+
- **Documentation** - Removed Docker references, simplified to user-managed environments
|
|
32
|
+
|
|
33
|
+
### Technical Details
|
|
34
|
+
|
|
35
|
+
- **Package structure** - Modern src/ layout with PEP 621 pyproject.toml
|
|
36
|
+
- **Type hints** - Complete type annotations across all modules
|
|
37
|
+
- **Docstrings** - NumPy-style documentation for all public functions
|
|
38
|
+
- **Testing** - pytest suite with 100% coverage of public API
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## [Unreleased]
|
|
43
|
+
|
|
44
|
+
### Added (Historical)
|
|
45
|
+
|
|
46
|
+
- **Workflow Instructions**: Added mandatory instructions for AI agents to
|
|
47
|
+
maintain `CHANGELOG.md` with each significant change, ensuring a transparent
|
|
48
|
+
and up-to-date project history without additional tools.
|
|
49
|
+
- **AI Agent Workflow**: Introduced a tool-agnostic agent instruction set to
|
|
50
|
+
ensure high-quality code and consistent scientific visualization across
|
|
51
|
+
different AI assistants (Copilot, Claude, Gemini).
|
|
52
|
+
- Refactored `AGENTS.md` into high-level mandates.
|
|
53
|
+
- Created `.agents/instructions/` for specialized coding, plotting,
|
|
54
|
+
documentation, and data handling standards.
|
|
55
|
+
- Created `.agents/skills/` for high-level task workflows.
|
|
56
|
+
- **Project Infrastructure**: Added `devenv` configuration and integrated
|
|
57
|
+
`pre-commit` hooks for automated linting and type checking.
|
|
58
|
+
|
|
59
|
+
### Changed (Historical)
|
|
60
|
+
|
|
61
|
+
- **Documentation**: Updated `README.md` with new project layout and AI agent
|
|
62
|
+
workflow details.
|
|
63
|
+
- **Tooling**: Updated `ty` type checking command to use the `check`
|
|
64
|
+
subcommand.
|
|
65
|
+
|
|
66
|
+
### Fixed (Historical)
|
|
67
|
+
|
|
68
|
+
- **Type Checking**: Resolved a `ty` warning in `MatplotlibStyle.py` by
|
|
69
|
+
removing an unused `type: ignore` directive.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
*Last Updated: 2026-05-07*
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jakob Buchmeier
|
|
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.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Acknowledgments
|
|
26
|
+
|
|
27
|
+
This package builds upon the excellent [SciencePlots](https://github.com/garrettj403/SciencePlots)
|
|
28
|
+
library by John Garrett, which is also licensed under the MIT License.
|
|
29
|
+
|
|
30
|
+
SciencePlots provides Matplotlib styles for publication-quality plots.
|
|
31
|
+
For more information, see: https://github.com/garrettj403/SciencePlots
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scienceplots-toolkit
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Publication-quality Matplotlib plotting utilities with SciencePlots styles and LaTeX typesetting
|
|
5
|
+
Project-URL: Homepage, https://github.com/jakobbuch/scienceplots-toolkit
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/jakobbuch/scienceplots-toolkit/issues
|
|
7
|
+
Project-URL: Source, https://github.com/jakobbuch/scienceplots-toolkit
|
|
8
|
+
Project-URL: Changelog, https://github.com/jakobbuch/scienceplots-toolkit/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Jakob Buchmeier <jakob.buchmeier@tuwien.ac.at>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Requires-Dist: cmap>=0.6.2
|
|
25
|
+
Requires-Dist: matplotlib>=3.10.7
|
|
26
|
+
Requires-Dist: scienceplots>=2.1.1
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pre-commit>=4.3.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
30
|
+
Requires-Dist: ty; extra == 'dev'
|
|
31
|
+
Provides-Extra: tests
|
|
32
|
+
Requires-Dist: numpy>=1.24; extra == 'tests'
|
|
33
|
+
Requires-Dist: pytest-cov>=4; extra == 'tests'
|
|
34
|
+
Requires-Dist: pytest>=8; extra == 'tests'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# SciencePlots Toolkit
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/scienceplots-toolkit)
|
|
40
|
+
[](https://pypi.org/project/scienceplots-toolkit)
|
|
41
|
+
[](https://github.com/jakobbuch/scienceplots-toolkit/blob/main/LICENSE)
|
|
42
|
+
|
|
43
|
+
Publication-quality Matplotlib plotting utilities with SciencePlots styles and LaTeX typesetting.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **Pre-configured SciencePlots styles** with professional defaults
|
|
48
|
+
- **LaTeX typesetting** for mathematical expressions and units
|
|
49
|
+
- **24-hour time axis** utilities for daily profiles
|
|
50
|
+
- **Statistical annotations** for average/peak values
|
|
51
|
+
- **Quantile shading** for uncertainty visualization
|
|
52
|
+
- **Multi-panel grid** generation for comparative plots
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
### From PyPI
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install scienceplots-toolkit
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### From source with uv
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/jakobbuch/scienceplots-toolkit.git
|
|
66
|
+
cd scienceplots-toolkit
|
|
67
|
+
uv sync
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### From source with pip
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/jakobbuch/scienceplots-toolkit.git
|
|
74
|
+
cd scienceplots-toolkit
|
|
75
|
+
pip install -e .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Quick Start
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from scienceplots_toolkit import configure_matplotlib_style, save_plot
|
|
82
|
+
from scienceplots_toolkit.utils import configure_24h_axis, add_stats_box
|
|
83
|
+
import matplotlib.pyplot as plt
|
|
84
|
+
import numpy as np
|
|
85
|
+
|
|
86
|
+
# Configure the style
|
|
87
|
+
configure_matplotlib_style(use_latex=True)
|
|
88
|
+
|
|
89
|
+
# Create a simple plot
|
|
90
|
+
fig, ax = plt.subplots()
|
|
91
|
+
x = np.linspace(0, 10, 400)
|
|
92
|
+
ax.plot(x, np.sin(x), label=r"$\sin(x)$")
|
|
93
|
+
ax.set_xlabel(r"Time (s)")
|
|
94
|
+
ax.set_ylabel(r"Amplitude")
|
|
95
|
+
ax.legend()
|
|
96
|
+
|
|
97
|
+
# Save the plot
|
|
98
|
+
save_plot(fig, "my_first_plot")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Examples
|
|
102
|
+
|
|
103
|
+
### Basic Plots
|
|
104
|
+
|
|
105
|
+
Run the basic examples to see all features in action:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Without LaTeX (uses mathtext)
|
|
109
|
+
uv run examples/example_basic.py
|
|
110
|
+
|
|
111
|
+
# With LaTeX rendering (requires LaTeX installation)
|
|
112
|
+
uv run examples/example_basic.py --latex
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Energy Profiles
|
|
116
|
+
|
|
117
|
+
Advanced examples with 24h load profiles and quantile shading:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
uv run examples/example_energy.py
|
|
121
|
+
uv run examples/example_energy.py --latex
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Generated plots are saved to the `output/` directory in both PNG and PDF formats.
|
|
125
|
+
|
|
126
|
+
## API Reference
|
|
127
|
+
|
|
128
|
+
### Style Configuration
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from scienceplots_toolkit import configure_matplotlib_style
|
|
132
|
+
|
|
133
|
+
configure_matplotlib_style(
|
|
134
|
+
styles=["science", "ieee", "grid"], # SciencePlots styles to use
|
|
135
|
+
grid_linewidth=3, # Grid line width in points
|
|
136
|
+
lines_linewidth=4, # Plot line width in points
|
|
137
|
+
fontsize=26, # Base font size
|
|
138
|
+
figsize=(16, 10), # Default figure size (inches)
|
|
139
|
+
font="serif", # Font family
|
|
140
|
+
sans_serif_math=False, # Use sans-serif for math
|
|
141
|
+
cmap_name="seaborn:tab10_new", # Qualitative colormap
|
|
142
|
+
use_latex=False, # Enable LaTeX rendering
|
|
143
|
+
grid=True, # Enable axis gridlines
|
|
144
|
+
legend_framealpha=1.0, # Legend background transparency
|
|
145
|
+
legend_shadow=True, # Legend shadow effect
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Utilities
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from scienceplots_toolkit.utils import (
|
|
153
|
+
save_plot, # Save figure to PNG and PDF
|
|
154
|
+
configure_24h_axis, # Set up 0-24h x-axis with 4h ticks
|
|
155
|
+
add_stats_box, # Add average/peak annotation box
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# Save a figure
|
|
159
|
+
save_plot(fig, "my_plot", dpi=300)
|
|
160
|
+
|
|
161
|
+
# Configure 24-hour axis
|
|
162
|
+
configure_24h_axis(ax)
|
|
163
|
+
|
|
164
|
+
# Add statistics box
|
|
165
|
+
add_stats_box(ax, avg=5.2, peak=12.3, unit=r"\text{kW}")
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Analysis Tools
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from scienceplots_toolkit import (
|
|
172
|
+
plot_profile_with_quantiles, # Plot mean with shaded quantiles
|
|
173
|
+
generate_profile_grid, # Create multi-panel grid of plots
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
# Plot with uncertainty shading
|
|
177
|
+
plot_profile_with_quantiles(
|
|
178
|
+
ax, x, mean, q10, q90,
|
|
179
|
+
label="Load Profile",
|
|
180
|
+
color="C0"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
# Create a 2x2 grid of subplots
|
|
184
|
+
fig, axes = generate_profile_grid(n_rows=2, n_cols=2)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## LaTeX Support
|
|
188
|
+
|
|
189
|
+
The package supports two modes:
|
|
190
|
+
|
|
191
|
+
1. **Mathtext (default)**: Uses Matplotlib's built-in math renderer. No external dependencies.
|
|
192
|
+
2. **LaTeX**: Uses system LaTeX for professional typesetting. Requires:
|
|
193
|
+
- TeX Live or MiKTeX installation
|
|
194
|
+
- Packages: `amsmath`, `amssymb`, `amsfonts`, `textcomp`, `gensymb`, `siunitx`, `graphicx`
|
|
195
|
+
|
|
196
|
+
Enable LaTeX mode:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
configure_matplotlib_style(use_latex=True)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Or via CLI:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
uv run examples/example_basic.py --latex
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Project Structure
|
|
209
|
+
|
|
210
|
+
```text
|
|
211
|
+
scienceplots-toolkit/
|
|
212
|
+
├── src/scienceplots_toolkit/
|
|
213
|
+
│ ├── __init__.py # Public API exports
|
|
214
|
+
│ ├── style.py # Matplotlib style configuration
|
|
215
|
+
│ ├── utils.py # Utility functions
|
|
216
|
+
│ └── analysis.py # Analysis and visualization tools
|
|
217
|
+
├── examples/
|
|
218
|
+
│ ├── example_basic.py # Basic plotting examples
|
|
219
|
+
│ └── example_energy.py # Energy profile examples
|
|
220
|
+
├── tests/
|
|
221
|
+
├── pyproject.toml
|
|
222
|
+
├── README.md
|
|
223
|
+
└── LICENSE
|
|
224
|
+
## Development
|
|
225
|
+
|
|
226
|
+
### Setup
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
uv sync --group dev
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Run Tests
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
uv run pytest tests/ -v
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Linting and Formatting
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
uv run ruff format .
|
|
242
|
+
uv run ruff check .
|
|
243
|
+
uv run ty check .
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Acknowledgments
|
|
247
|
+
|
|
248
|
+
This package builds upon the excellent [SciencePlots](https://github.com/garrettj403/SciencePlots) library by John Garrett, which is also licensed under the MIT License.
|
|
249
|
+
|
|
250
|
+
SciencePlots provides Matplotlib styles for publication-quality plots. For more information, see: <https://github.com/garrettj403/SciencePlots>
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
Distributed under the MIT License. See [LICENSE](LICENSE) for details.
|
|
255
|
+
|
|
256
|
+
## Contact
|
|
257
|
+
|
|
258
|
+
Jakob Buchmeier - <jakob.buchmeier@tuwien.ac.at>
|
|
259
|
+
|
|
260
|
+
Project Link: <https://github.com/jakobbuch/scienceplots-toolkit>
|