poikilos 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.
- poikilos-1.0.0/.github/workflows/ci.yml +40 -0
- poikilos-1.0.0/.github/workflows/publish.yml +20 -0
- poikilos-1.0.0/.gitignore +220 -0
- poikilos-1.0.0/CHANGELOG.md +106 -0
- poikilos-1.0.0/LICENSE +21 -0
- poikilos-1.0.0/PKG-INFO +282 -0
- poikilos-1.0.0/README.md +268 -0
- poikilos-1.0.0/pyproject.toml +43 -0
- poikilos-1.0.0/scripts/gallery.py +141 -0
- poikilos-1.0.0/scripts/lilaq_parity.py +141 -0
- poikilos-1.0.0/skill/SKILL.md +155 -0
- poikilos-1.0.0/skill/references/fonts.md +91 -0
- poikilos-1.0.0/skill/references/lilaq.md +78 -0
- poikilos-1.0.0/skill/references/migration.md +115 -0
- poikilos-1.0.0/skill/references/pgl.md +63 -0
- poikilos-1.0.0/skill/references/plain.md +125 -0
- poikilos-1.0.0/src/poikilos/__init__.py +17 -0
- poikilos-1.0.0/src/poikilos/base.mplstyle +8 -0
- poikilos-1.0.0/src/poikilos/helpers.py +380 -0
- poikilos-1.0.0/src/poikilos/looks/lilaq.mplstyle +53 -0
- poikilos-1.0.0/src/poikilos/looks/pgl.mplstyle +19 -0
- poikilos-1.0.0/src/poikilos/looks/plain.mplstyle +10 -0
- poikilos-1.0.0/src/poikilos/palettes/lilaq-moon.toml +13 -0
- poikilos-1.0.0/src/poikilos/palettes/lilaq.toml +13 -0
- poikilos-1.0.0/src/poikilos/palettes/pgl.toml +23 -0
- poikilos-1.0.0/src/poikilos/palettes/plain-dark.toml +23 -0
- poikilos-1.0.0/src/poikilos/palettes/plain.toml +23 -0
- poikilos-1.0.0/src/poikilos/palettes/rose-pine-dawn.toml +28 -0
- poikilos-1.0.0/src/poikilos/palettes/rose-pine-moon.toml +28 -0
- poikilos-1.0.0/src/poikilos/palettes/rose-pine.toml +28 -0
- poikilos-1.0.0/src/poikilos/themes.py +235 -0
- poikilos-1.0.0/tests/baseline/3.11/lilaq-moon.png +0 -0
- poikilos-1.0.0/tests/baseline/3.11/lilaq.png +0 -0
- poikilos-1.0.0/tests/baseline/3.11/pgl.png +0 -0
- poikilos-1.0.0/tests/baseline/3.11/plain-dark.png +0 -0
- poikilos-1.0.0/tests/baseline/3.11/plain.png +0 -0
- poikilos-1.0.0/tests/baseline/3.11/rose-pine-dawn.png +0 -0
- poikilos-1.0.0/tests/baseline/3.11/rose-pine-moon.png +0 -0
- poikilos-1.0.0/tests/baseline/3.11/rose-pine.png +0 -0
- poikilos-1.0.0/tests/conftest.py +10 -0
- poikilos-1.0.0/tests/test_helpers.py +667 -0
- poikilos-1.0.0/tests/test_images.py +53 -0
- poikilos-1.0.0/tests/test_themes.py +209 -0
- poikilos-1.0.0/uv.lock +1043 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
# Oldest and newest Python. The lowest job also runs 3.11, but with an old numpy.
|
|
14
|
+
python-version: ["3.11", "3.14"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v7
|
|
17
|
+
# setup-uv publishes no major tags since v8, only immutable release tags.
|
|
18
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- run: uv sync --locked
|
|
22
|
+
- run: uv run ruff check
|
|
23
|
+
- run: uv run ruff format --check
|
|
24
|
+
- run: uv run pytest
|
|
25
|
+
# The editable install reads files from src/, so only the wheel shows missing package data.
|
|
26
|
+
- run: uv build --wheel
|
|
27
|
+
- run: |
|
|
28
|
+
files=$(unzip -Z1 dist/*.whl)
|
|
29
|
+
for f in poikilos/base.mplstyle poikilos/looks/ poikilos/palettes/; do
|
|
30
|
+
grep -q "^$f" <<< "$files" || { echo "wheel lacks $f"; exit 1; }
|
|
31
|
+
done
|
|
32
|
+
|
|
33
|
+
lowest:
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v7
|
|
37
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
38
|
+
with:
|
|
39
|
+
python-version: "3.11"
|
|
40
|
+
- run: uv run --resolution lowest-direct pytest -m "not images"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
# PyPI's trusted publisher for poikilos names this environment.
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
- uses: astral-sh/setup-uv@v10.2.0
|
|
17
|
+
# PyPI never accepts a version twice, so a tag that disagrees with pyproject.toml must not publish.
|
|
18
|
+
- run: test "${GITHUB_REF_NAME#v}" = "$(uv version --short)"
|
|
19
|
+
- run: uv build
|
|
20
|
+
- run: uv publish --trusted-publishing always
|
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
*.lcov
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
# Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# UV
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi/*
|
|
127
|
+
!.pixi/config.toml
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule*
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# pytype static type analyzer
|
|
181
|
+
.pytype/
|
|
182
|
+
|
|
183
|
+
# Cython debug symbols
|
|
184
|
+
cython_debug/
|
|
185
|
+
|
|
186
|
+
# PyCharm
|
|
187
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
188
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
189
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
190
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
191
|
+
# .idea/
|
|
192
|
+
|
|
193
|
+
# Abstra
|
|
194
|
+
# Abstra is an AI-powered process automation framework.
|
|
195
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
196
|
+
# Learn more at https://abstra.io/docs
|
|
197
|
+
.abstra/
|
|
198
|
+
|
|
199
|
+
# Visual Studio Code
|
|
200
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
201
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
202
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
203
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
204
|
+
# .vscode/
|
|
205
|
+
# Temporary file for partial code execution
|
|
206
|
+
tempCodeRunnerFile.py
|
|
207
|
+
|
|
208
|
+
# Ruff stuff:
|
|
209
|
+
.ruff_cache/
|
|
210
|
+
|
|
211
|
+
# PyPI configuration file
|
|
212
|
+
.pypirc
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# Streamlit
|
|
220
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Versions follow [Semantic Versioning](https://semver.org). The public API is
|
|
4
|
+
every name in `poikilos.__all__`, every theme name and each theme's look.
|
|
5
|
+
|
|
6
|
+
- Renaming or removing a theme, or any public name, is a major release. Each
|
|
7
|
+
such change goes under "Breaking".
|
|
8
|
+
- A new theme, palette, look or helper is a minor release.
|
|
9
|
+
- A visual change to an existing theme is a minor release. It comes with new
|
|
10
|
+
image baselines and a line here.
|
|
11
|
+
- A bug fix that leaves the API and the looks alone is a patch release.
|
|
12
|
+
|
|
13
|
+
## 1.0.0 (2026-10-17)
|
|
14
|
+
|
|
15
|
+
`matplotlib-rosepine` 0.2.0 is now `poikilos` 1.0.0. The distribution and the
|
|
16
|
+
import package are both `poikilos`. The rename breaks code written for 0.2.0,
|
|
17
|
+
so the major version goes up.
|
|
18
|
+
|
|
19
|
+
### Breaking
|
|
20
|
+
|
|
21
|
+
| `matplotlib_rosepine` 0.2.0 | `poikilos` 1.0.0 |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `import matplotlib_rosepine as rp` | `import poikilos as pk` |
|
|
24
|
+
| `rp.apply_style(v)` before importing pyplot | `pk.use(v)`, before or after importing pyplot |
|
|
25
|
+
| `rp.style_path(v)` | `pk.rc_params(v)` returns the settings as a dict |
|
|
26
|
+
| `rp.VARIANTS` | `pk.THEMES` (now 8 themes) |
|
|
27
|
+
| `rp.register()`, `plt.style.use("rose-pine")` | removed; use `pk.use("rose-pine")` |
|
|
28
|
+
| Rosé Pine hex values copied by hand | `pk.PALETTES["rose-pine-dawn"].colors["love"]` |
|
|
29
|
+
|
|
30
|
+
- `use()` never sets the backend. `apply_style()` forced Agg.
|
|
31
|
+
- Importing the package no longer registers styles or changes rcParams.
|
|
32
|
+
- The themes set `savefig.dpi: 300` instead of `figure.dpi: 300`. Saved files
|
|
33
|
+
keep their resolution. Figures on screen and in notebooks use matplotlib's
|
|
34
|
+
100 dpi, and `fig.dpi` reads 100 unless you pass `dpi=`.
|
|
35
|
+
- A figure's own dpi no longer sets the saved resolution. `plt.figure(dpi=150)`
|
|
36
|
+
used to save at 150 dpi and now saves at 300. Pass `dpi=` to `save_figure`
|
|
37
|
+
to change it.
|
|
38
|
+
- `save_figure` keeps dots in the stem: `x.curve` gives `x.curve.svg` and
|
|
39
|
+
`x.curve.png`. It used to write `x.svg` and `x.png`.
|
|
40
|
+
- Removed `template.mplstyle`, the generated `.mplstyle` files and the
|
|
41
|
+
rose-pine-bloom step. Palettes are TOML files now.
|
|
42
|
+
- Needs Python 3.11 and matplotlib 3.11.
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- Themes `plain`, `plain-dark`, `lilaq`, `lilaq-moon` and `pgl`, next to the
|
|
47
|
+
three Rosé Pine themes.
|
|
48
|
+
- `use(theme, *, palette=None, rc=None)`, `context(...)` and `rc_params(...)`.
|
|
49
|
+
Any look takes any palette, and `rc` overrides any rcParam.
|
|
50
|
+
- `PALETTES`, with each palette's colors as hex, and `THEMES`.
|
|
51
|
+
- `zero_line(ax, axis="y")` draws a bold line at zero, for values that change
|
|
52
|
+
sign.
|
|
53
|
+
- `fit_legend(fig)` grows the figure so legends outside the axes keep the
|
|
54
|
+
axes at their size without the legends.
|
|
55
|
+
- `label_points(..., offsets=[(dx, dy), ...])` places labels at fixed offsets
|
|
56
|
+
in points, without adjustText. `leader=False` drops the leader lines.
|
|
57
|
+
- `save_figure(..., formats=("pdf", "png"))` picks the formats to write.
|
|
58
|
+
- `save_figure` writes SVG and PDF files without a creation date. The themes
|
|
59
|
+
fix `svg.hashsalt`. Reruns write the same bytes.
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- As before, no theme sets `pdf.fonttype`, so PDFs use matplotlib's Type 3 fonts.
|
|
64
|
+
`rc={"pdf.fonttype": 42}` gives TrueType. The default fonts are CFF, and with
|
|
65
|
+
them it writes a PDF that breaks the spec.
|
|
66
|
+
- `despine` hides top and right tick marks, so it works on looks that mirror
|
|
67
|
+
ticks. On a categorical axis it hides minor ticks too.
|
|
68
|
+
- `despine` leaves lines without data clipped, such as the flier line of a
|
|
69
|
+
boxplot with no outliers. Unclipped, it pulled constrained layout to the
|
|
70
|
+
figure corner.
|
|
71
|
+
- `label_points` runs a fixed 1000 adjustText iterations instead of adjustText's
|
|
72
|
+
1 s time limit. The same figure with the same fonts now gets the same labels
|
|
73
|
+
on any machine. Markers push labels away twice as hard as adjustText's
|
|
74
|
+
default.
|
|
75
|
+
- `label_points` draws each label in a rounded box with the legend frame's
|
|
76
|
+
face. The box outline and the leader line to the marker share one stroke
|
|
77
|
+
in the axes edge color. adjustText keeps the boxes apart and off the
|
|
78
|
+
markers. `bbox=None` gives bare labels.
|
|
79
|
+
- `label_points` keeps labels off the axes edge by the legend's gap to it,
|
|
80
|
+
`legend.borderaxespad`. adjustText alone let boxes touch the frame.
|
|
81
|
+
- Title, legend label, legend face and `savefig` face colors now inherit from
|
|
82
|
+
the palette's root colors instead of repeating them. 2D Rosé Pine figures
|
|
83
|
+
render pixel-identical at the same save dpi.
|
|
84
|
+
- 3D panes take the background color instead of matplotlib's translucent grey.
|
|
85
|
+
|
|
86
|
+
### Fixed
|
|
87
|
+
|
|
88
|
+
- `despine` raised `TypeError` on Python 3.11 with numpy 2.3 or later.
|
|
89
|
+
- `despine` keeps clipping on when a log axis leaves out values at or below 0,
|
|
90
|
+
such as the base of each bar. Unclipped, log bar charts collapsed constrained
|
|
91
|
+
layout and lost tick labels.
|
|
92
|
+
- `despine` unclips every panel of shared axes, such as seaborn facets. Only
|
|
93
|
+
the first panel used to draw edge markers whole. Explicit limits that hold
|
|
94
|
+
all the data now unclip too.
|
|
95
|
+
- `despine` picks ticks for the axes size after layout. It picked them before
|
|
96
|
+
layout, so an axes that layout shrank, such as one beside long category
|
|
97
|
+
names, kept too many ticks and their labels overlapped. Axes that layout
|
|
98
|
+
resizes can get a different tick step.
|
|
99
|
+
- `despine` fixes the limits of a categorical axis. A twin drawn after
|
|
100
|
+
`despine` refitted them with its own margins and moved the bars off the
|
|
101
|
+
spine.
|
|
102
|
+
- `despine` no longer offsets a categorical axis. Its labels sat 10 pt farther
|
|
103
|
+
from the bars or cells than the tick padding.
|
|
104
|
+
- `despine` keeps styling set on tick labels, such as rotation. Moving the
|
|
105
|
+
spines used to reset rotated labels to horizontal. Long category names then
|
|
106
|
+
overlapped.
|
poikilos-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Christian Samuel Ramirez
|
|
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.
|
poikilos-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: poikilos
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Matplotlib themes and figure helpers
|
|
5
|
+
Author-email: Christian Samuel Ramirez <chrisram0403@proton.me>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: lilaq,matplotlib,plotting,rose-pine,style,theme
|
|
9
|
+
Requires-Python: >=3.11
|
|
10
|
+
Requires-Dist: matplotlib>=3.11
|
|
11
|
+
Provides-Extra: labels
|
|
12
|
+
Requires-Dist: adjusttext>=1.4.0; extra == 'labels'
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# poikilos
|
|
16
|
+
|
|
17
|
+
Matplotlib themes, plus five helpers for publication figures. *Poikilos* is
|
|
18
|
+
Greek for many-colored.
|
|
19
|
+
|
|
20
|
+
A theme is a look (fonts, spines, ticks, sizes) plus a palette (colors). Any
|
|
21
|
+
look takes any palette.
|
|
22
|
+
|
|
23
|
+
| Theme | Look | Palette |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `plain`, `plain-dark` | plain | matplotlib's tab10 on white or `#242424` |
|
|
26
|
+
| `rose-pine`, `rose-pine-moon`, `rose-pine-dawn` | plain | [Rosé Pine](https://rosepinetheme.com) |
|
|
27
|
+
| `lilaq`, `lilaq-moon` | lilaq | [lilaq](https://lilaq.org) 0.6.0, default and moon |
|
|
28
|
+
| `pgl` | pgl | seaborn's whitegrid greys, tab10 |
|
|
29
|
+
|
|
30
|
+
| Light | Dark |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
|  |  |
|
|
33
|
+
|  |  |
|
|
34
|
+
|  |  |
|
|
35
|
+
|  | |
|
|
36
|
+
|
|
37
|
+
[`rose-pine-moon`](https://github.com/ramirc0/poikilos/blob/main/assets/gallery/rose-pine-moon.png)
|
|
38
|
+
has its own gallery image.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv add "poikilos @ git+https://github.com/ramirc0/poikilos"
|
|
44
|
+
uv add "poikilos[labels] @ git+https://github.com/ramirc0/poikilos" # adds adjustText for label_points
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Needs Python 3.11 and matplotlib 3.11 or later.
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import matplotlib.pyplot as plt
|
|
53
|
+
|
|
54
|
+
import poikilos as pk
|
|
55
|
+
|
|
56
|
+
pk.use("rose-pine")
|
|
57
|
+
|
|
58
|
+
fig, ax = plt.subplots()
|
|
59
|
+
ax.plot([0, 1, 2], [0, 1, 0])
|
|
60
|
+
pk.despine(ax)
|
|
61
|
+
pk.save_figure(fig, "results/plot") # writes plot.svg and plot.png
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`use()` resets every style rcParam to matplotlib's default, then applies the
|
|
65
|
+
theme. It leaves the backend alone, so it works before or after importing
|
|
66
|
+
pyplot. Importing `poikilos` changes nothing.
|
|
67
|
+
|
|
68
|
+
For one figure in another theme, use `context()`. It restores the previous
|
|
69
|
+
rcParams on exit. Save inside the block, because matplotlib reads
|
|
70
|
+
`savefig.dpi` at save time.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
with pk.context("lilaq"):
|
|
74
|
+
fig, ax = plt.subplots()
|
|
75
|
+
ax.plot(x, y)
|
|
76
|
+
pk.save_figure(fig, "results/lilaq")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Mixing and overrides
|
|
80
|
+
|
|
81
|
+
`palette=` puts another palette on a theme's look. `rc=` sets any rcParams on
|
|
82
|
+
top. `use()`, `context()` and `rc_params()` all take both.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
pk.use("lilaq", palette="rose-pine-dawn") # lilaq look, Rosé Pine Dawn colors
|
|
86
|
+
pk.use("plain", rc={"axes.grid": True})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
`use()` validates everything before it touches matplotlib. A misspelled key in
|
|
90
|
+
`rc` raises `KeyError` and a bad value raises `ValueError`. Either way the
|
|
91
|
+
current rcParams stay as they were. The next `use()` resets any rcParam you set
|
|
92
|
+
by hand, so set them after `use()` or pass them in `rc`.
|
|
93
|
+
|
|
94
|
+
seaborn's `set_theme()` also resets rcParams. Call it before `pk.use()`.
|
|
95
|
+
|
|
96
|
+
`pk.rc_params(theme, palette=None)` returns a theme's rcParams as a dict
|
|
97
|
+
without applying them.
|
|
98
|
+
|
|
99
|
+
### Palettes as data
|
|
100
|
+
|
|
101
|
+
Palettes are TOML files in `src/poikilos/palettes/`. `pk.PALETTES` holds them
|
|
102
|
+
with every color resolved to hex:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
dawn = pk.PALETTES["rose-pine-dawn"]
|
|
106
|
+
dawn.background # '#faf4ed'
|
|
107
|
+
dawn.cycle # ('#b4637a', '#ea9d34', ...)
|
|
108
|
+
dawn.colors["love"] # '#b4637a', by the palette's own name
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`pk.THEMES` maps each theme name to its `(look, palette)` pair.
|
|
112
|
+
|
|
113
|
+
A palette sets root colors only: background, foreground, frame, ticks, grid,
|
|
114
|
+
legend edge, boxplot median and mean, and the cycle. Legend face, title,
|
|
115
|
+
`savefig` and hatch colors inherit from those. An `rc=` override of a root
|
|
116
|
+
color therefore carries through to them.
|
|
117
|
+
|
|
118
|
+
## Helpers
|
|
119
|
+
|
|
120
|
+
- `despine(ax, categorical_x=False, categorical_y=False)` fits each continuous
|
|
121
|
+
axis to its data and widens it to the enclosing ticks. It then offsets the
|
|
122
|
+
left and bottom spines by 10 pt and trims them to the end ticks. The top and
|
|
123
|
+
right spines and their ticks go. Pass `categorical_x=True` for bar charts,
|
|
124
|
+
`categorical_y=True` for horizontal bars, and both for heatmaps. A categorical
|
|
125
|
+
axis has no spine or offset, so its labels sit by the data. Call it after
|
|
126
|
+
everything on the figure is drawn. It picks ticks for the axes size after
|
|
127
|
+
layout.
|
|
128
|
+
- `fit_legend(fig)` grows the figure by the room legends outside the axes
|
|
129
|
+
take. Constrained layout otherwise keeps `figsize` and shrinks the axes, so
|
|
130
|
+
a square plot turns into a rectangle. The figure ends up larger than
|
|
131
|
+
`figsize`. Call it after adding every legend, before `despine`.
|
|
132
|
+
- `label_points(ax, points, labels, offsets=None, leader=True, **text_kwargs)`
|
|
133
|
+
labels the collection
|
|
134
|
+
`ax.scatter` returns. Each label sits in a box outlined like its leader
|
|
135
|
+
line, or stays bare with `bbox=None`. It moves labels off each other and off
|
|
136
|
+
the markers, but a label can still touch a marker. That happens most near
|
|
137
|
+
the edge of the axes, since labels stay inside them. Call it last, after
|
|
138
|
+
`despine` and every title and legend. Needs the `labels` extra.
|
|
139
|
+
`offsets=[(dx, dy), ...]`, in points, fixes each label's place instead and
|
|
140
|
+
needs no extra. `leader=False` drops the leader lines.
|
|
141
|
+
- `save_figure(fig, path, formats=("svg", "png"), **savefig_kwargs)` writes
|
|
142
|
+
`path.svg` and `path.png`, or one file per entry in `formats`. It drops a
|
|
143
|
+
suffix that names a format, such as `.svg` or `.pdf`, and keeps any other
|
|
144
|
+
dots, so `x.curve` gives `x.curve.svg` and `x.curve.png`.
|
|
145
|
+
- `zero_line(ax, axis="y", **line_kwargs)` draws a bold line at zero, for
|
|
146
|
+
values that change sign. It uses the frame color at twice the grid width.
|
|
147
|
+
`axis="x"` draws x = 0 and `"both"` draws both. The limits widen to include
|
|
148
|
+
zero.
|
|
149
|
+
|
|
150
|
+
## Recipes per look
|
|
151
|
+
|
|
152
|
+
Looks only set rcParams. Anything that needs code per axes is a recipe.
|
|
153
|
+
|
|
154
|
+
**plain.** Call `despine` on every axes. Without it you get matplotlib's
|
|
155
|
+
default frame minus the top and right spines. `despine` styles the left and
|
|
156
|
+
bottom spines only, so style a twin axes by hand:
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
ax2 = ax.twinx()
|
|
160
|
+
ax2.plot(x, y2, clip_on=False) # despine never sees the twin
|
|
161
|
+
ax2.set_ylim(0, 100) # limits on ticks, so the spine ends on one
|
|
162
|
+
ax2.spines[["left", "bottom"]].set_visible(False)
|
|
163
|
+
ax2.spines["right"].set_visible(True) # the look hides right spines
|
|
164
|
+
ax2.spines["right"].set_position(("outward", 10))
|
|
165
|
+
pk.despine(ax) # last, once the twin is drawn
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**lilaq.** lilaq's tick steps and dotted lines take a few lines of code:
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from matplotlib.ticker import MaxNLocator, NullLocator
|
|
172
|
+
|
|
173
|
+
ax.plot(x, y, marker="o") # lilaq draws a dot at every data point
|
|
174
|
+
for axis in (ax.xaxis, ax.yaxis):
|
|
175
|
+
axis.set_major_locator(MaxNLocator(7, steps=[1, 2, 5, 10]))
|
|
176
|
+
ax.xaxis.set_minor_locator(NullLocator()) # instead, on a categorical axis
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
lilaq rounds the step to 1, 2 or 5 and scales the tick count with the axis
|
|
180
|
+
length. That gives about five ticks on its default 6 × 4 cm plot, where
|
|
181
|
+
`nbins=7` switches steps at nearly the same data ranges. On axes of another
|
|
182
|
+
size, lilaq picks a different count. The dots stay out of the look
|
|
183
|
+
on purpose. A `marker` in `axes.prop_cycle` makes `plot(color="k")` use up a
|
|
184
|
+
cycle slot and beads dense lines. seaborn would also apply it unevenly.
|
|
185
|
+
`scatterplot` and `pointplot` drop it. `lineplot` keeps it but leaves it out of
|
|
186
|
+
the legend, and without `hue` takes the marker from the wrong cycle slot.
|
|
187
|
+
|
|
188
|
+
**pgl.** The Programmable Genomics Laboratory's papers use seaborn's
|
|
189
|
+
`whitegrid` without spines, with a dashed grid in place of tick marks. This look
|
|
190
|
+
follows them. Never call `despine` on it, because that brings the spines back.
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
ax.xaxis.grid(False) # categorical x; seaborn's categorical plots already do this
|
|
194
|
+
pk.zero_line(ax) # values change sign; axis="x" for x = 0
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Heatmaps need `ax.grid(False)`. To sign positive tick labels on a scale that
|
|
198
|
+
runs from − to +:
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from matplotlib.ticker import ScalarFormatter
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class SignedFormatter(ScalarFormatter):
|
|
205
|
+
def __call__(self, x, pos=None):
|
|
206
|
+
text = super().__call__(x, pos)
|
|
207
|
+
return f"+{text}" if x > 0 and text.strip("0.") else text
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
ax.xaxis.set_major_formatter(SignedFormatter())
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
It keeps matplotlib's formatting, so `+1.50` sits next to `−0.50`.
|
|
214
|
+
|
|
215
|
+
**PDF text as TrueType.** `rc={"pdf.fonttype": 42}` embeds fonts as TrueType.
|
|
216
|
+
Use it only with a TrueType font. Anthropic Sans Text and New Computer Modern
|
|
217
|
+
are CFF (`.otf`) fonts. So is Overpass from Debian's `fonts-overpass` package.
|
|
218
|
+
With them, matplotlib writes CFF outlines into a TrueType font stream. Common
|
|
219
|
+
viewers still render that PDF, but it breaks the PDF spec and strict checkers
|
|
220
|
+
flag it.
|
|
221
|
+
|
|
222
|
+
## Fonts
|
|
223
|
+
|
|
224
|
+
No fonts ship with poikilos. Each look names a fallback chain that ends in a
|
|
225
|
+
DejaVu family bundled with matplotlib, so a missing font falls back silently.
|
|
226
|
+
|
|
227
|
+
- plain: Anthropic Sans Text, Google Sans Flex, Arimo, Arial, DejaVu Sans.
|
|
228
|
+
- lilaq: New Computer Modern, Palatino Linotype, P052, DejaVu Serif. Math uses
|
|
229
|
+
matplotlib's bundled Computer Modern.
|
|
230
|
+
- pgl: Overpass, Arial, Arimo, DejaVu Sans.
|
|
231
|
+
|
|
232
|
+
matplotlib knows New Computer Modern as `NewComputerModern`. From
|
|
233
|
+
[CTAN](https://ctan.org/pkg/newcomputermodern), install only the 10 pt cuts
|
|
234
|
+
Typst uses: `NewCM10-Regular.otf`, `NewCM10-Italic.otf`, `NewCM10-Bold.otf`,
|
|
235
|
+
`NewCM10-BoldItalic.otf` and `NewCMMath-Regular.otf`. The 8 pt and Book cuts
|
|
236
|
+
register under the same family and weight, and matplotlib may pick any of them.
|
|
237
|
+
|
|
238
|
+
After installing a font, delete matplotlib's font cache so it rescans:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
rm "$(python -c 'import matplotlib; print(matplotlib.get_cachedir())')"/fontlist-*.json
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Check that a family resolves without falling back:
|
|
245
|
+
|
|
246
|
+
```python
|
|
247
|
+
from matplotlib.font_manager import FontProperties, findfont
|
|
248
|
+
|
|
249
|
+
findfont(FontProperties(family="NewComputerModern"), fallback_to_default=False)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The themes set `svg.fonttype: none`, so an SVG names its font instead of
|
|
253
|
+
embedding it. A viewer without the font shows a substitute. PNGs look the same
|
|
254
|
+
everywhere.
|
|
255
|
+
|
|
256
|
+
## Limits
|
|
257
|
+
|
|
258
|
+
- matplotlib hard-codes the colors of `table` cells, `quiver`, `barbs` and
|
|
259
|
+
`spy`. Palettes do not reach them.
|
|
260
|
+
- rcParams cannot fix the size of the data area. The lilaq look's figure size
|
|
261
|
+
gives about lilaq's 6 × 4 cm for a plot with a title and both axis labels.
|
|
262
|
+
- matplotlib's `scatter` draws from its own color cycle, separate from `plot`.
|
|
263
|
+
- Some cycle colors have under 3:1 contrast with their background, such as two
|
|
264
|
+
petroff10 colors on `lilaq-moon`. `scripts/gallery.py` prints the ratios.
|
|
265
|
+
Text has at least 4.5:1 in every palette, and a test checks it.
|
|
266
|
+
|
|
267
|
+
## Development
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
uv sync
|
|
271
|
+
uv run pytest # includes image tests against tests/baseline/3.11
|
|
272
|
+
uv run ruff check && uv run ruff format --check
|
|
273
|
+
uv run python scripts/gallery.py # regenerate assets/gallery
|
|
274
|
+
uv run python scripts/lilaq_parity.py # compare with lilaq 0.6.0 in build/parity
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
[CHANGELOG.md](https://github.com/ramirc0/poikilos/blob/main/CHANGELOG.md) has
|
|
278
|
+
the version history and the versioning rules.
|
|
279
|
+
|
|
280
|
+
## License
|
|
281
|
+
|
|
282
|
+
MIT (see `LICENSE`).
|