hwostyle 1.0.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.
- hwostyle-1.0.0/.gitignore +207 -0
- hwostyle-1.0.0/.pre-commit-config.yaml +20 -0
- hwostyle-1.0.0/.readthedocs.yaml +20 -0
- hwostyle-1.0.0/CHANGELOG.md +18 -0
- hwostyle-1.0.0/LICENSE +21 -0
- hwostyle-1.0.0/PKG-INFO +122 -0
- hwostyle-1.0.0/README.md +68 -0
- hwostyle-1.0.0/pyproject.toml +61 -0
- hwostyle-1.0.0/src/hwostyle/__init__.py +202 -0
- hwostyle-1.0.0/src/hwostyle/_version.py +34 -0
- hwostyle-1.0.0/src/hwostyle/colormaps.py +126 -0
- hwostyle-1.0.0/src/hwostyle/palette.py +122 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: "v6.0.0"
|
|
4
|
+
hooks:
|
|
5
|
+
- id: trailing-whitespace
|
|
6
|
+
- id: name-tests-test
|
|
7
|
+
args: [--pytest-test-first]
|
|
8
|
+
- id: end-of-file-fixer
|
|
9
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
10
|
+
rev: v0.15.2
|
|
11
|
+
hooks:
|
|
12
|
+
- id: ruff-check
|
|
13
|
+
args: [--fix]
|
|
14
|
+
- id: ruff-format
|
|
15
|
+
- repo: https://github.com/compilerla/conventional-pre-commit
|
|
16
|
+
rev: v4.3.0
|
|
17
|
+
hooks:
|
|
18
|
+
- id: conventional-pre-commit
|
|
19
|
+
stages: [commit-msg]
|
|
20
|
+
args: []
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Required
|
|
2
|
+
version: 2
|
|
3
|
+
|
|
4
|
+
# Set the OS, Python version and other tools you might need
|
|
5
|
+
build:
|
|
6
|
+
os: ubuntu-22.04
|
|
7
|
+
tools:
|
|
8
|
+
python: "3.12"
|
|
9
|
+
|
|
10
|
+
python:
|
|
11
|
+
install:
|
|
12
|
+
- method: pip
|
|
13
|
+
path: .
|
|
14
|
+
extra_requirements:
|
|
15
|
+
# Install with the [docs] flag for sphinx docs specific extensions
|
|
16
|
+
- docs
|
|
17
|
+
|
|
18
|
+
# Build documentation in the "docs/" directory with Sphinx
|
|
19
|
+
sphinx:
|
|
20
|
+
configuration: docs/conf.py
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2026-03-02)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* Initial setup ([fa40f01](https://github.com/CoreySpohn/hwostyle/commit/fa40f01a6dc3f3e4d9011ade329011d5f212b852))
|
|
9
|
+
|
|
10
|
+
## 0.1.0 (Unreleased)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- Dual-mode style system: `use("dark")` for talks, `use("light")` for papers
|
|
15
|
+
- Color palette with 6 named colors (cyan, pink, yellow, green, red, purple)
|
|
16
|
+
- Semantic colormap registry (`cmaps.intensity`, `cmaps.residual`, etc.)
|
|
17
|
+
- Context managers `dark()` and `light()` that auto-restore previous mode
|
|
18
|
+
- Custom brand colormaps: `hwo_intensity`, `hwo_diverging`
|
hwostyle-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Corey Spohn
|
|
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.
|
hwostyle-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hwostyle
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Matplotlib style sheets and utilities for HWO direct imaging figures. Dual-mode dark (talks) and light (papers) themes with domain-specific colormaps.
|
|
5
|
+
Project-URL: Homepage, https://github.com/CoreySpohn/hwostyle
|
|
6
|
+
Project-URL: Issues, https://github.com/CoreySpohn/hwostyle/issues
|
|
7
|
+
Author-email: Corey Spohn <corey.a.spohn@nasa.gov>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 Corey Spohn
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Classifier: Development Status :: 3 - Alpha
|
|
31
|
+
Classifier: Intended Audience :: Science/Research
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
35
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
36
|
+
Requires-Python: >=3.11
|
|
37
|
+
Requires-Dist: cycler
|
|
38
|
+
Requires-Dist: matplotlib>=3.8
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pre-commit; extra == 'dev'
|
|
41
|
+
Provides-Extra: docs
|
|
42
|
+
Requires-Dist: ipython; extra == 'docs'
|
|
43
|
+
Requires-Dist: matplotlib; extra == 'docs'
|
|
44
|
+
Requires-Dist: myst-nb; extra == 'docs'
|
|
45
|
+
Requires-Dist: sphinx; extra == 'docs'
|
|
46
|
+
Requires-Dist: sphinx-autoapi; extra == 'docs'
|
|
47
|
+
Requires-Dist: sphinx-autodoc-typehints; extra == 'docs'
|
|
48
|
+
Requires-Dist: sphinx-book-theme; extra == 'docs'
|
|
49
|
+
Provides-Extra: test
|
|
50
|
+
Requires-Dist: nox; extra == 'test'
|
|
51
|
+
Requires-Dist: pytest; extra == 'test'
|
|
52
|
+
Requires-Dist: pytest-cov; extra == 'test'
|
|
53
|
+
Description-Content-Type: text/markdown
|
|
54
|
+
|
|
55
|
+
# hwostyle
|
|
56
|
+
|
|
57
|
+
Matplotlib style sheets and utilities for HWO direct imaging figures.
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install hwostyle
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
For development:
|
|
66
|
+
```bash
|
|
67
|
+
git clone https://github.com/CoreySpohn/hwostyle.git
|
|
68
|
+
cd hwostyle
|
|
69
|
+
pip install -e ".[dev,test]"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
import hwostyle
|
|
76
|
+
|
|
77
|
+
# Switch to paper mode (white background, muted colors)
|
|
78
|
+
hwostyle.use("light")
|
|
79
|
+
|
|
80
|
+
# Switch to talk mode (black background, neon colors)
|
|
81
|
+
hwostyle.use("dark")
|
|
82
|
+
|
|
83
|
+
# Access the palette
|
|
84
|
+
colors = hwostyle.palette
|
|
85
|
+
colors.cyan # '#08F7FE' in dark, '#0097A7' in light
|
|
86
|
+
|
|
87
|
+
# Use domain-specific colormaps
|
|
88
|
+
cmap = hwostyle.cmaps.intensity # PSF images
|
|
89
|
+
cmap = hwostyle.cmaps.residual # difference maps
|
|
90
|
+
cmap = hwostyle.cmaps.phase # wavefront error
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Modes
|
|
94
|
+
|
|
95
|
+
| Feature | Dark (Talks) | Light (Papers) | Barbie |
|
|
96
|
+
|---------|-------------|----------------|--------|
|
|
97
|
+
| Background | Black | White | White |
|
|
98
|
+
| Colors | Neon (high saturation) | Muted (print-safe) | RdPu pinks |
|
|
99
|
+
| Line width | 2.5 | 1.5 | 1.0 |
|
|
100
|
+
| Font | Sans-serif | Sans-serif | Serif |
|
|
101
|
+
| Image cmap | `magma` | `viridis` | `RdPu` |
|
|
102
|
+
|
|
103
|
+
## Color Palette
|
|
104
|
+
|
|
105
|
+
| Name | Dark | Light |
|
|
106
|
+
|--------|-------------|-------------|
|
|
107
|
+
| Cyan | `#08F7FE` | `#0097A7` |
|
|
108
|
+
| Pink | `#FE53BB` | `#C2185B` |
|
|
109
|
+
| Yellow | `#F5D300` | `#F9A825` |
|
|
110
|
+
| Green | `#00FF41` | `#2E7D32` |
|
|
111
|
+
| Red | `#FF0000` | `#D32F2F` |
|
|
112
|
+
| Purple | `#9467BD` | `#7B1FA2` |
|
|
113
|
+
|
|
114
|
+
### Barbie Palette
|
|
115
|
+
|
|
116
|
+
| Name | Hex |
|
|
117
|
+
|---------|-----------|
|
|
118
|
+
| Blush | `#FAA6B7` |
|
|
119
|
+
| Rose | `#F768A1` |
|
|
120
|
+
| Magenta | `#D42A92` |
|
|
121
|
+
| Berry | `#9A017B` |
|
|
122
|
+
| Plum | `#5E006F` |
|
hwostyle-1.0.0/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# hwostyle
|
|
2
|
+
|
|
3
|
+
Matplotlib style sheets and utilities for HWO direct imaging figures.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install hwostyle
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For development:
|
|
12
|
+
```bash
|
|
13
|
+
git clone https://github.com/CoreySpohn/hwostyle.git
|
|
14
|
+
cd hwostyle
|
|
15
|
+
pip install -e ".[dev,test]"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import hwostyle
|
|
22
|
+
|
|
23
|
+
# Switch to paper mode (white background, muted colors)
|
|
24
|
+
hwostyle.use("light")
|
|
25
|
+
|
|
26
|
+
# Switch to talk mode (black background, neon colors)
|
|
27
|
+
hwostyle.use("dark")
|
|
28
|
+
|
|
29
|
+
# Access the palette
|
|
30
|
+
colors = hwostyle.palette
|
|
31
|
+
colors.cyan # '#08F7FE' in dark, '#0097A7' in light
|
|
32
|
+
|
|
33
|
+
# Use domain-specific colormaps
|
|
34
|
+
cmap = hwostyle.cmaps.intensity # PSF images
|
|
35
|
+
cmap = hwostyle.cmaps.residual # difference maps
|
|
36
|
+
cmap = hwostyle.cmaps.phase # wavefront error
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Modes
|
|
40
|
+
|
|
41
|
+
| Feature | Dark (Talks) | Light (Papers) | Barbie |
|
|
42
|
+
|---------|-------------|----------------|--------|
|
|
43
|
+
| Background | Black | White | White |
|
|
44
|
+
| Colors | Neon (high saturation) | Muted (print-safe) | RdPu pinks |
|
|
45
|
+
| Line width | 2.5 | 1.5 | 1.0 |
|
|
46
|
+
| Font | Sans-serif | Sans-serif | Serif |
|
|
47
|
+
| Image cmap | `magma` | `viridis` | `RdPu` |
|
|
48
|
+
|
|
49
|
+
## Color Palette
|
|
50
|
+
|
|
51
|
+
| Name | Dark | Light |
|
|
52
|
+
|--------|-------------|-------------|
|
|
53
|
+
| Cyan | `#08F7FE` | `#0097A7` |
|
|
54
|
+
| Pink | `#FE53BB` | `#C2185B` |
|
|
55
|
+
| Yellow | `#F5D300` | `#F9A825` |
|
|
56
|
+
| Green | `#00FF41` | `#2E7D32` |
|
|
57
|
+
| Red | `#FF0000` | `#D32F2F` |
|
|
58
|
+
| Purple | `#9467BD` | `#7B1FA2` |
|
|
59
|
+
|
|
60
|
+
### Barbie Palette
|
|
61
|
+
|
|
62
|
+
| Name | Hex |
|
|
63
|
+
|---------|-----------|
|
|
64
|
+
| Blush | `#FAA6B7` |
|
|
65
|
+
| Rose | `#F768A1` |
|
|
66
|
+
| Magenta | `#D42A92` |
|
|
67
|
+
| Berry | `#9A017B` |
|
|
68
|
+
| Plum | `#5E006F` |
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ['hatchling', "hatch-fancy-pypi-readme", "hatch-vcs"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hwostyle"
|
|
7
|
+
description = "Matplotlib style sheets and utilities for HWO direct imaging figures. Dual-mode dark (talks) and light (papers) themes with domain-specific colormaps."
|
|
8
|
+
authors = [{ name = "Corey Spohn", email = "corey.a.spohn@nasa.gov" }]
|
|
9
|
+
dynamic = ['readme', 'version']
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Intended Audience :: Science/Research",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Topic :: Scientific/Engineering :: Astronomy",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
19
|
+
]
|
|
20
|
+
dependencies = ["matplotlib>=3.8", "cycler"]
|
|
21
|
+
|
|
22
|
+
[project.optional-dependencies]
|
|
23
|
+
dev = ["pre-commit"]
|
|
24
|
+
docs = [
|
|
25
|
+
"sphinx",
|
|
26
|
+
"myst-nb",
|
|
27
|
+
"sphinx-book-theme",
|
|
28
|
+
"sphinx-autoapi",
|
|
29
|
+
"sphinx_autodoc_typehints",
|
|
30
|
+
"ipython",
|
|
31
|
+
"matplotlib",
|
|
32
|
+
]
|
|
33
|
+
test = ["nox", "pytest", "pytest-cov"]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Homepage = "https://github.com/CoreySpohn/hwostyle"
|
|
37
|
+
Issues = "https://github.com/CoreySpohn/hwostyle/issues"
|
|
38
|
+
|
|
39
|
+
[tool.hatch.version]
|
|
40
|
+
source = "vcs"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.build.hooks.vcs]
|
|
43
|
+
version-file = "src/hwostyle/_version.py"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.metadata.hooks.fancy-pypi-readme]
|
|
46
|
+
content-type = "text/markdown"
|
|
47
|
+
|
|
48
|
+
[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
|
|
49
|
+
path = "README.md"
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.wheel]
|
|
52
|
+
packages = ["src/hwostyle"]
|
|
53
|
+
|
|
54
|
+
[tool.hatch.build.targets.sdist]
|
|
55
|
+
exclude = ["/docs", "/tests", "/.github"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff.lint]
|
|
58
|
+
select = ["B", "D", "E", "F", "I", "UP", "RUF"]
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint.pydocstyle]
|
|
61
|
+
convention = "google"
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""hwostyle: Matplotlib style sheets and utilities for HWO figures.
|
|
2
|
+
|
|
3
|
+
Provides a dual-mode (dark/light/barbie) visual style with consistent colors,
|
|
4
|
+
colormaps, and rcParams for talks and papers.
|
|
5
|
+
|
|
6
|
+
Usage::
|
|
7
|
+
|
|
8
|
+
import hwostyle
|
|
9
|
+
|
|
10
|
+
# Switch to paper mode
|
|
11
|
+
hwostyle.use("light")
|
|
12
|
+
|
|
13
|
+
# Switch to talk mode
|
|
14
|
+
hwostyle.use("dark")
|
|
15
|
+
|
|
16
|
+
# Access colors and colormaps
|
|
17
|
+
hwostyle.palette.cyan
|
|
18
|
+
hwostyle.cmaps.intensity
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from contextlib import contextmanager
|
|
22
|
+
|
|
23
|
+
import matplotlib.pyplot as plt
|
|
24
|
+
from cycler import cycler
|
|
25
|
+
|
|
26
|
+
from .colormaps import Colormaps
|
|
27
|
+
from .palette import Palette
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
from ._version import __version__
|
|
31
|
+
except ModuleNotFoundError:
|
|
32
|
+
__version__ = "0.0.0.dev"
|
|
33
|
+
|
|
34
|
+
# Global state
|
|
35
|
+
_current_mode = "dark"
|
|
36
|
+
palette = Palette("dark")
|
|
37
|
+
cmaps = Colormaps("dark")
|
|
38
|
+
|
|
39
|
+
# --- rcParams definitions ---
|
|
40
|
+
|
|
41
|
+
_SHARED_RC = {
|
|
42
|
+
"font.family": "sans-serif",
|
|
43
|
+
"font.sans-serif": ["Inter", "Helvetica", "Arial"],
|
|
44
|
+
"font.size": 12,
|
|
45
|
+
"axes.titlesize": 14,
|
|
46
|
+
"axes.labelsize": 13,
|
|
47
|
+
"xtick.labelsize": 11,
|
|
48
|
+
"ytick.labelsize": 11,
|
|
49
|
+
"legend.fontsize": 10,
|
|
50
|
+
"figure.titlesize": 16,
|
|
51
|
+
"axes.grid": True,
|
|
52
|
+
"grid.alpha": 0.3,
|
|
53
|
+
"axes.spines.top": False,
|
|
54
|
+
"axes.spines.right": False,
|
|
55
|
+
"figure.figsize": (7, 5),
|
|
56
|
+
"savefig.dpi": 300,
|
|
57
|
+
"savefig.bbox": "tight",
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_DARK_RC = {
|
|
61
|
+
"figure.facecolor": "black",
|
|
62
|
+
"axes.facecolor": "black",
|
|
63
|
+
"axes.edgecolor": "#444444",
|
|
64
|
+
"axes.labelcolor": "white",
|
|
65
|
+
"text.color": "white",
|
|
66
|
+
"xtick.color": "white",
|
|
67
|
+
"ytick.color": "white",
|
|
68
|
+
"grid.color": "#333333",
|
|
69
|
+
"legend.facecolor": "#1a1a1a",
|
|
70
|
+
"legend.edgecolor": "#444444",
|
|
71
|
+
"legend.labelcolor": "white",
|
|
72
|
+
"lines.linewidth": 2.5,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
_LIGHT_RC = {
|
|
76
|
+
"figure.facecolor": "white",
|
|
77
|
+
"axes.facecolor": "white",
|
|
78
|
+
"axes.edgecolor": "#333333",
|
|
79
|
+
"axes.labelcolor": "black",
|
|
80
|
+
"text.color": "black",
|
|
81
|
+
"xtick.color": "black",
|
|
82
|
+
"ytick.color": "black",
|
|
83
|
+
"grid.color": "#cccccc",
|
|
84
|
+
"legend.facecolor": "white",
|
|
85
|
+
"legend.edgecolor": "#999999",
|
|
86
|
+
"legend.labelcolor": "black",
|
|
87
|
+
"lines.linewidth": 1.5,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
_BARBIE_RC = {
|
|
91
|
+
"figure.facecolor": "white",
|
|
92
|
+
"axes.facecolor": "white",
|
|
93
|
+
"axes.edgecolor": "#333333",
|
|
94
|
+
"axes.labelcolor": "black",
|
|
95
|
+
"text.color": "black",
|
|
96
|
+
"xtick.color": "black",
|
|
97
|
+
"ytick.color": "black",
|
|
98
|
+
"grid.color": "#cccccc",
|
|
99
|
+
"legend.facecolor": "white",
|
|
100
|
+
"legend.edgecolor": "#999999",
|
|
101
|
+
"legend.labelcolor": "black",
|
|
102
|
+
"lines.linewidth": 1.0,
|
|
103
|
+
"font.family": "serif",
|
|
104
|
+
"font.size": 12,
|
|
105
|
+
"axes.labelsize": 16,
|
|
106
|
+
"axes.titlesize": 16,
|
|
107
|
+
"xtick.labelsize": 14,
|
|
108
|
+
"ytick.labelsize": 14,
|
|
109
|
+
"legend.fontsize": 14,
|
|
110
|
+
"image.cmap": "RdPu",
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def use(mode):
|
|
115
|
+
"""Switch the global style mode.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
mode: Either "dark" (talks, posters) or "light" (papers, print).
|
|
119
|
+
|
|
120
|
+
Raises:
|
|
121
|
+
ValueError: If mode is not "dark" or "light".
|
|
122
|
+
"""
|
|
123
|
+
global _current_mode, palette, cmaps
|
|
124
|
+
|
|
125
|
+
if mode not in ("dark", "light", "barbie"):
|
|
126
|
+
msg = f"Mode must be 'dark', 'light', or 'barbie', got '{mode}'"
|
|
127
|
+
raise ValueError(msg)
|
|
128
|
+
|
|
129
|
+
_current_mode = mode
|
|
130
|
+
palette = Palette(mode)
|
|
131
|
+
cmaps = Colormaps(mode)
|
|
132
|
+
|
|
133
|
+
rc = {**_SHARED_RC}
|
|
134
|
+
mode_rc = {"dark": _DARK_RC, "light": _LIGHT_RC, "barbie": _BARBIE_RC}
|
|
135
|
+
rc.update(mode_rc[mode])
|
|
136
|
+
|
|
137
|
+
rc["axes.prop_cycle"] = cycler(color=palette.as_list)
|
|
138
|
+
plt.rcParams.update(rc)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@contextmanager
|
|
142
|
+
def dark():
|
|
143
|
+
"""Context manager for dark mode. Restores previous mode on exit.
|
|
144
|
+
|
|
145
|
+
Usage::
|
|
146
|
+
|
|
147
|
+
with hwo_style.dark():
|
|
148
|
+
fig, ax = plt.subplots()
|
|
149
|
+
ax.plot(x, y)
|
|
150
|
+
"""
|
|
151
|
+
previous = _current_mode
|
|
152
|
+
use("dark")
|
|
153
|
+
try:
|
|
154
|
+
yield
|
|
155
|
+
finally:
|
|
156
|
+
use(previous)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@contextmanager
|
|
160
|
+
def light():
|
|
161
|
+
"""Context manager for light mode. Restores previous mode on exit.
|
|
162
|
+
|
|
163
|
+
Usage::
|
|
164
|
+
|
|
165
|
+
with hwo_style.light():
|
|
166
|
+
fig, ax = plt.subplots()
|
|
167
|
+
ax.plot(x, y)
|
|
168
|
+
"""
|
|
169
|
+
previous = _current_mode
|
|
170
|
+
use("light")
|
|
171
|
+
try:
|
|
172
|
+
yield
|
|
173
|
+
finally:
|
|
174
|
+
use(previous)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
@contextmanager
|
|
178
|
+
def barbie():
|
|
179
|
+
"""Context manager for barbie mode. Restores previous mode on exit.
|
|
180
|
+
|
|
181
|
+
Usage::
|
|
182
|
+
|
|
183
|
+
with hwo_style.barbie():
|
|
184
|
+
fig, ax = plt.subplots()
|
|
185
|
+
ax.plot(x, y)
|
|
186
|
+
"""
|
|
187
|
+
previous = _current_mode
|
|
188
|
+
use("barbie")
|
|
189
|
+
try:
|
|
190
|
+
yield
|
|
191
|
+
finally:
|
|
192
|
+
use(previous)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
__all__ = [
|
|
196
|
+
"barbie",
|
|
197
|
+
"cmaps",
|
|
198
|
+
"dark",
|
|
199
|
+
"light",
|
|
200
|
+
"palette",
|
|
201
|
+
"use",
|
|
202
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# file generated by setuptools-scm
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"__version__",
|
|
6
|
+
"__version_tuple__",
|
|
7
|
+
"version",
|
|
8
|
+
"version_tuple",
|
|
9
|
+
"__commit_id__",
|
|
10
|
+
"commit_id",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
TYPE_CHECKING = False
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from typing import Tuple
|
|
16
|
+
from typing import Union
|
|
17
|
+
|
|
18
|
+
VERSION_TUPLE = Tuple[Union[int, str], ...]
|
|
19
|
+
COMMIT_ID = Union[str, None]
|
|
20
|
+
else:
|
|
21
|
+
VERSION_TUPLE = object
|
|
22
|
+
COMMIT_ID = object
|
|
23
|
+
|
|
24
|
+
version: str
|
|
25
|
+
__version__: str
|
|
26
|
+
__version_tuple__: VERSION_TUPLE
|
|
27
|
+
version_tuple: VERSION_TUPLE
|
|
28
|
+
commit_id: COMMIT_ID
|
|
29
|
+
__commit_id__: COMMIT_ID
|
|
30
|
+
|
|
31
|
+
__version__ = version = '1.0.0'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 0, 0)
|
|
33
|
+
|
|
34
|
+
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""Domain-specific colormap registry for HWO figures."""
|
|
2
|
+
|
|
3
|
+
from matplotlib.colors import LinearSegmentedColormap
|
|
4
|
+
|
|
5
|
+
from .palette import DARK_COLORS, LIGHT_COLORS
|
|
6
|
+
|
|
7
|
+
# --- Custom colormaps built from the brand palette ---
|
|
8
|
+
|
|
9
|
+
_hwo_intensity_dark = LinearSegmentedColormap.from_list(
|
|
10
|
+
"hwo_intensity_dark",
|
|
11
|
+
["#000000", DARK_COLORS["cyan"], "#FFFFFF"],
|
|
12
|
+
N=256,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
_hwo_intensity_light = LinearSegmentedColormap.from_list(
|
|
16
|
+
"hwo_intensity_light",
|
|
17
|
+
["#FFFFFF", LIGHT_COLORS["cyan"], "#000000"],
|
|
18
|
+
N=256,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
_hwo_diverging_dark = LinearSegmentedColormap.from_list(
|
|
22
|
+
"hwo_diverging_dark",
|
|
23
|
+
[DARK_COLORS["pink"], "#000000", DARK_COLORS["cyan"]],
|
|
24
|
+
N=256,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
_hwo_diverging_light = LinearSegmentedColormap.from_list(
|
|
28
|
+
"hwo_diverging_light",
|
|
29
|
+
[LIGHT_COLORS["pink"], "#FFFFFF", LIGHT_COLORS["cyan"]],
|
|
30
|
+
N=256,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Colormaps:
|
|
35
|
+
"""Mode-aware colormap registry with semantic names.
|
|
36
|
+
|
|
37
|
+
Access colormaps by their intended use rather than by name. The returned
|
|
38
|
+
colormap depends on the current mode (dark or light).
|
|
39
|
+
|
|
40
|
+
Colormap categories:
|
|
41
|
+
- **intensity**: PSF images, focal plane count rates, throughput maps.
|
|
42
|
+
Perceptually uniform, monotonic lightness.
|
|
43
|
+
- **high_dynamic_range**: Stellar intensity, coronagraph images spanning
|
|
44
|
+
5+ decades. High contrast over extreme ranges.
|
|
45
|
+
- **residual**: Difference images, signed error maps. Diverging with
|
|
46
|
+
a clear zero crossing.
|
|
47
|
+
- **phase**: Wavefront error, position angles. Cyclic/periodic, wraps
|
|
48
|
+
smoothly at boundaries.
|
|
49
|
+
- **mask**: Aperture masks, boolean maps, sky transmission.
|
|
50
|
+
Two-tone, high contrast.
|
|
51
|
+
- **probability**: Completeness, detection probability, SNR maps.
|
|
52
|
+
Intuitive (0 = bad, 1 = good), print-safe.
|
|
53
|
+
- **brand_intensity**: Custom sequential cmap built from the brand
|
|
54
|
+
palette colors.
|
|
55
|
+
- **brand_diverging**: Custom diverging cmap (pink-to-cyan) through
|
|
56
|
+
black (dark) or white (light).
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def __init__(self, mode="dark"):
|
|
60
|
+
"""Initialize colormaps for the given mode.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
mode: Either "dark", "light", or "barbie".
|
|
64
|
+
"""
|
|
65
|
+
self._mode = mode
|
|
66
|
+
|
|
67
|
+
@property
|
|
68
|
+
def intensity(self):
|
|
69
|
+
"""Sequential cmap for PSF images and focal plane intensities."""
|
|
70
|
+
cmap_map = {"dark": "magma", "light": "viridis", "barbie": "RdPu"}
|
|
71
|
+
return cmap_map[self._mode]
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def high_dynamic_range(self):
|
|
75
|
+
"""Sequential cmap for data spanning many decades."""
|
|
76
|
+
cmap_map = {"dark": "inferno", "light": "cividis", "barbie": "RdPu"}
|
|
77
|
+
return cmap_map[self._mode]
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def residual(self):
|
|
81
|
+
"""Diverging cmap for difference images and signed errors."""
|
|
82
|
+
return "RdBu_r"
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def phase(self):
|
|
86
|
+
"""Cyclic cmap for phase maps and wavefront error."""
|
|
87
|
+
return "twilight"
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def mask(self):
|
|
91
|
+
"""Two-tone cmap for binary masks and apertures."""
|
|
92
|
+
if self._mode == "dark":
|
|
93
|
+
return LinearSegmentedColormap.from_list(
|
|
94
|
+
"hwo_mask_dark", ["#000000", DARK_COLORS["cyan"]], N=2
|
|
95
|
+
)
|
|
96
|
+
if self._mode == "barbie":
|
|
97
|
+
return LinearSegmentedColormap.from_list(
|
|
98
|
+
"hwo_mask_barbie", ["#FFFFFF", "#D42A92"], N=2
|
|
99
|
+
)
|
|
100
|
+
return LinearSegmentedColormap.from_list(
|
|
101
|
+
"hwo_mask_light", ["#FFFFFF", LIGHT_COLORS["cyan"]], N=2
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def probability(self):
|
|
106
|
+
"""Sequential cmap for probabilities, completeness, SNR."""
|
|
107
|
+
cmap_map = {"dark": "plasma", "light": "YlOrRd_r", "barbie": "RdPu"}
|
|
108
|
+
return cmap_map[self._mode]
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def brand_intensity(self):
|
|
112
|
+
"""Custom sequential cmap from the brand palette."""
|
|
113
|
+
if self._mode == "dark":
|
|
114
|
+
return _hwo_intensity_dark
|
|
115
|
+
return _hwo_intensity_light
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def brand_diverging(self):
|
|
119
|
+
"""Custom diverging cmap (pink-to-cyan) from the brand palette."""
|
|
120
|
+
if self._mode == "dark":
|
|
121
|
+
return _hwo_diverging_dark
|
|
122
|
+
return _hwo_diverging_light
|
|
123
|
+
|
|
124
|
+
def __repr__(self):
|
|
125
|
+
"""String representation."""
|
|
126
|
+
return f"Colormaps(mode='{self._mode}')"
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""Color palette definitions for hwo-style."""
|
|
2
|
+
|
|
3
|
+
from cycler import cycler
|
|
4
|
+
|
|
5
|
+
# Dark mode: cyberpunk neons for talks, posters, animations
|
|
6
|
+
DARK_COLORS = {
|
|
7
|
+
"cyan": "#08F7FE",
|
|
8
|
+
"pink": "#FE53BB",
|
|
9
|
+
"yellow": "#F5D300",
|
|
10
|
+
"green": "#00FF41",
|
|
11
|
+
"red": "#FF0000",
|
|
12
|
+
"purple": "#9467BD",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
# Light mode: de-saturated variants for papers and print
|
|
16
|
+
LIGHT_COLORS = {
|
|
17
|
+
"cyan": "#0097A7",
|
|
18
|
+
"pink": "#C2185B",
|
|
19
|
+
"yellow": "#F9A825",
|
|
20
|
+
"green": "#2E7D32",
|
|
21
|
+
"red": "#D32F2F",
|
|
22
|
+
"purple": "#7B1FA2",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
# Barbie mode: RdPu-sampled pinks for a collaborator's visual style
|
|
26
|
+
BARBIE_COLORS = {
|
|
27
|
+
"blush": "#FAA6B7",
|
|
28
|
+
"rose": "#F768A1",
|
|
29
|
+
"magenta": "#D42A92",
|
|
30
|
+
"berry": "#9A017B",
|
|
31
|
+
"plum": "#5E006F",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Palette:
|
|
36
|
+
"""Mode-aware color palette.
|
|
37
|
+
|
|
38
|
+
Provides named color access and a matplotlib cycler for the current mode.
|
|
39
|
+
|
|
40
|
+
Attributes:
|
|
41
|
+
cyan: Primary color.
|
|
42
|
+
pink: Secondary color.
|
|
43
|
+
yellow: Tertiary color.
|
|
44
|
+
green: Quaternary color.
|
|
45
|
+
red: Error / alert color.
|
|
46
|
+
purple: Sixth series color.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def __init__(self, mode="dark"):
|
|
50
|
+
"""Initialize palette for the given mode.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
mode: Either "dark", "light", or "barbie".
|
|
54
|
+
"""
|
|
55
|
+
self._mode = mode
|
|
56
|
+
color_map = {
|
|
57
|
+
"dark": DARK_COLORS,
|
|
58
|
+
"light": LIGHT_COLORS,
|
|
59
|
+
"barbie": BARBIE_COLORS,
|
|
60
|
+
}
|
|
61
|
+
self._colors = color_map[mode]
|
|
62
|
+
|
|
63
|
+
@property
|
|
64
|
+
def mode(self):
|
|
65
|
+
"""Current mode name."""
|
|
66
|
+
return self._mode
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def cyan(self):
|
|
70
|
+
"""Primary color."""
|
|
71
|
+
return self._colors["cyan"]
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def pink(self):
|
|
75
|
+
"""Secondary color."""
|
|
76
|
+
return self._colors["pink"]
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def yellow(self):
|
|
80
|
+
"""Tertiary color."""
|
|
81
|
+
return self._colors["yellow"]
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def green(self):
|
|
85
|
+
"""Quaternary color."""
|
|
86
|
+
return self._colors["green"]
|
|
87
|
+
|
|
88
|
+
@property
|
|
89
|
+
def red(self):
|
|
90
|
+
"""Error / alert color."""
|
|
91
|
+
return self._colors["red"]
|
|
92
|
+
|
|
93
|
+
@property
|
|
94
|
+
def purple(self):
|
|
95
|
+
"""Sixth series color."""
|
|
96
|
+
return self._colors["purple"]
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
def as_list(self):
|
|
100
|
+
"""All colors as a list in canonical order."""
|
|
101
|
+
return list(self._colors.values())
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def cycler(self):
|
|
105
|
+
"""Matplotlib color cycler for the current palette."""
|
|
106
|
+
return cycler(color=self.as_list)
|
|
107
|
+
|
|
108
|
+
def __getitem__(self, idx):
|
|
109
|
+
"""Access color by index."""
|
|
110
|
+
return self.as_list[idx]
|
|
111
|
+
|
|
112
|
+
def __iter__(self):
|
|
113
|
+
"""Iterate over colors."""
|
|
114
|
+
return iter(self.as_list)
|
|
115
|
+
|
|
116
|
+
def __len__(self):
|
|
117
|
+
"""Number of colors in the palette."""
|
|
118
|
+
return len(self._colors)
|
|
119
|
+
|
|
120
|
+
def __repr__(self):
|
|
121
|
+
"""String representation."""
|
|
122
|
+
return f"Palette(mode='{self._mode}', colors={self.as_list})"
|