charite-plot 0.1.0__tar.gz → 0.2.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.
- {charite_plot-0.1.0 → charite_plot-0.2.0}/.gitignore +1 -0
- charite_plot-0.2.0/CHANGELOG.md +38 -0
- charite_plot-0.2.0/CITATION.cff +19 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/LICENSE.md +4 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/PKG-INFO +41 -12
- {charite_plot-0.1.0 → charite_plot-0.2.0}/README.md +25 -6
- {charite_plot-0.1.0 → charite_plot-0.2.0}/charite_plot/__init__.py +1 -1
- charite_plot-0.2.0/charite_plot/_theme_common.py +55 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/charite_plot/altair_themes.py +62 -39
- {charite_plot-0.1.0 → charite_plot-0.2.0}/charite_plot/fonts.py +2 -2
- charite_plot-0.2.0/charite_plot/mpl_themes.py +188 -0
- charite_plot-0.2.0/charite_plot/py.typed +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/altair.md +15 -1
- charite_plot-0.2.0/docs/assets/theme_example.png +0 -0
- charite_plot-0.2.0/docs/citing.md +20 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/index.md +1 -1
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/installation.md +3 -2
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/matplotlib.md +15 -1
- {charite_plot-0.1.0 → charite_plot-0.2.0}/examples/mpl_showcase.py +3 -1
- charite_plot-0.2.0/examples/palette_preview.py +61 -0
- charite_plot-0.2.0/examples/poly_showcase.py +107 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/mkdocs.yml +2 -1
- {charite_plot-0.1.0 → charite_plot-0.2.0}/pyproject.toml +11 -5
- charite_plot-0.1.0/charite_plot/mpl_themes.py +0 -129
- charite_plot-0.1.0/docs/assets/theme_example.png +0 -0
- charite_plot-0.1.0/examples/palette_preview.py +0 -47
- charite_plot-0.1.0/examples/poly_showcase.py +0 -108
- {charite_plot-0.1.0 → charite_plot-0.2.0}/.github/workflows/ci.yml +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/charite_plot/colors.py +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/charite_plot/palettes.py +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/api/altair_themes.md +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/api/colors.md +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/api/fonts.md +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/api/mpl_themes.md +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/api/palettes.md +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/assets/palette_preview.png +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/colors.md +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/palettes.md +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/docs/stylesheets/extra.css +0 -0
- {charite_plot-0.1.0 → charite_plot-0.2.0}/examples/altair_showcase.py +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
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.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.2.0] - 2026-07-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `theme_charite` (matplotlib) gained `interactive` and `tiny_margins` parameters.
|
|
13
|
+
- `theme_charite` (Altair) gained `thickness` and `tiny_margins` parameters, bringing it to parity with the matplotlib backend.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Font-size ramp is now shared between both backends: labels scale at 1× and legend text at 0.8× the base size. Altair legend labels are slightly smaller and axis labels slightly larger as a result.
|
|
18
|
+
|
|
19
|
+
## [0.1.1] - 2026-06-13
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- README images now use absolute raw GitHub URLs so they render correctly on PyPI.
|
|
24
|
+
- Corrected PyPI project URLs (homepage, docs, repository, bug tracker).
|
|
25
|
+
|
|
26
|
+
## [0.1.0] - 2026-06-12
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- Initial release.
|
|
31
|
+
- Matplotlib theme (`mpl_themes.theme_charite`) with `apply_theme()` and `using()` context manager.
|
|
32
|
+
- Altair/Vega-Lite theme (`altair_themes.theme_charite`) with `register()` and `enable()`.
|
|
33
|
+
- 10 built-in colour palettes: `primary`, `secondary`, `mono`, `light`, `versus`, `nineties`, `brickhouse`, `sunrise`, `berryseason`, `goldelse`.
|
|
34
|
+
- 27 Charité corporate identity colour constants in `colors.py`.
|
|
35
|
+
- `make_palette()` for subsampling and interpolating palettes.
|
|
36
|
+
- Font fallback chain: Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans → sans-serif.
|
|
37
|
+
- MkDocs Material documentation with API reference.
|
|
38
|
+
- MIT License.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below."
|
|
3
|
+
type: software
|
|
4
|
+
title: "charite-plot: Matplotlib and Altair Themes for Charité – Universitätsmedizin Berlin"
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: Ramezani
|
|
7
|
+
given-names: Pedram
|
|
8
|
+
email: pedram.ramezani@charite.de
|
|
9
|
+
version: 0.2.0
|
|
10
|
+
date-released: 2026-07-01
|
|
11
|
+
license: MIT
|
|
12
|
+
url: "https://github.com/pedramezani/charite-plot"
|
|
13
|
+
repository-code: "https://github.com/pedramezani/charite-plot"
|
|
14
|
+
keywords:
|
|
15
|
+
- matplotlib
|
|
16
|
+
- altair
|
|
17
|
+
- theme
|
|
18
|
+
- visualization
|
|
19
|
+
- charite
|
|
@@ -7,3 +7,7 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
7
7
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
8
|
|
|
9
9
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
This package is based on the original `charite` R package developed by Johannes Julius Mohn (https://github.com/johannesjuliusm/charite), which is also distributed under the MIT License.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: charite-plot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Matplotlib and Altair themes for Charité – Universitätsmedizin Berlin
|
|
5
|
-
Project-URL: Homepage, https://github.com/
|
|
6
|
-
Project-URL: Documentation, https://
|
|
7
|
-
Project-URL: Repository, https://github.com/
|
|
8
|
-
Project-URL: Bug Tracker, https://github.com/
|
|
9
|
-
|
|
5
|
+
Project-URL: Homepage, https://github.com/pedramezani/charite-plot
|
|
6
|
+
Project-URL: Documentation, https://pedramezani.github.io/charite-plot
|
|
7
|
+
Project-URL: Repository, https://github.com/pedramezani/charite-plot
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/pedramezani/charite-plot/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/pedramezani/charite-plot/blob/main/CHANGELOG.md
|
|
10
|
+
Author-email: Pedram Ramezani <me@pedramramezani.de>
|
|
10
11
|
License: # MIT License
|
|
11
12
|
|
|
12
13
|
Copyright 2026 Pedram Ramezani
|
|
@@ -16,17 +17,26 @@ License: # MIT License
|
|
|
16
17
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
17
18
|
|
|
18
19
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
This package is based on the original `charite` R package developed by Johannes Julius Mohn (https://github.com/johannesjuliusm/charite), which is also distributed under the MIT License.
|
|
19
24
|
License-File: LICENSE.md
|
|
20
25
|
Keywords: altair,charite,matplotlib,theme,visualization
|
|
21
26
|
Classifier: Development Status :: 3 - Alpha
|
|
27
|
+
Classifier: Framework :: Matplotlib
|
|
22
28
|
Classifier: Intended Audience :: Science/Research
|
|
23
29
|
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Operating System :: OS Independent
|
|
24
31
|
Classifier: Programming Language :: Python :: 3
|
|
25
32
|
Classifier: Programming Language :: Python :: 3.9
|
|
26
33
|
Classifier: Programming Language :: Python :: 3.10
|
|
27
34
|
Classifier: Programming Language :: Python :: 3.11
|
|
28
35
|
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
29
38
|
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
39
|
+
Classifier: Typing :: Typed
|
|
30
40
|
Requires-Python: >=3.9
|
|
31
41
|
Requires-Dist: cycler
|
|
32
42
|
Requires-Dist: matplotlib>=3.5
|
|
@@ -57,13 +67,13 @@ pip install "charite-plot[altair]" # with Altair support
|
|
|
57
67
|
Visualize your data with `theme_charite()` to match the Charité corporate style.
|
|
58
68
|
|
|
59
69
|
<p align="center">
|
|
60
|
-
<img src="docs/assets/theme_example.png" width="80%"/>
|
|
70
|
+
<img src="https://raw.githubusercontent.com/pedramezani/charite-plot/main/docs/assets/theme_example.png" width="80%"/>
|
|
61
71
|
</p>
|
|
62
72
|
|
|
63
73
|
Preview the available colour palettes.
|
|
64
74
|
|
|
65
75
|
<p align="center">
|
|
66
|
-
<img src="docs/assets/palette_preview.png" width="80%"/>
|
|
76
|
+
<img src="https://raw.githubusercontent.com/pedramezani/charite-plot/main/docs/assets/palette_preview.png" width="80%"/>
|
|
67
77
|
</p>
|
|
68
78
|
|
|
69
79
|
## Quick start
|
|
@@ -126,16 +136,35 @@ enable(palette="berryseason", font_size=13)
|
|
|
126
136
|
|
|
127
137
|
The fallback chain follows the official Charité brand guidelines:
|
|
128
138
|
|
|
129
|
-
**Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans**
|
|
130
|
-
|
|
131
|
-
> **Ersatzschrift „Calibri"** — Falls die Hausschrift aus technischen Gründen nicht verwendet werden kann, ersetzt die Systemschriftart „Calibri" die Hausschrift. Dies ist beispielsweise bei der E-Mail-Korrespondenz der Fall.
|
|
139
|
+
**Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans → sans-serif**
|
|
132
140
|
|
|
133
|
-
`DejaVu Sans` ships with Matplotlib and is always available as the
|
|
141
|
+
`DejaVu Sans` ships with Matplotlib and is always available as the penultimate fallback; `sans-serif` lets the browser or system choose if nothing else matches (important for Altair/Vega-Lite). To override the preferred font:
|
|
134
142
|
|
|
135
143
|
```python
|
|
136
144
|
apply_theme(theme_charite(font="Arial"))
|
|
137
145
|
```
|
|
138
146
|
|
|
147
|
+
## How to cite
|
|
148
|
+
|
|
149
|
+
If you use charite-plot in your work, please cite it as:
|
|
150
|
+
|
|
151
|
+
```bibtex
|
|
152
|
+
@software{ramezani2026chariteplot,
|
|
153
|
+
author = {Ramezani, Pedram},
|
|
154
|
+
title = {charite-plot: Matplotlib and Altair Themes for Charité – Universitätsmedizin Berlin},
|
|
155
|
+
year = {2026},
|
|
156
|
+
version = {0.2.0},
|
|
157
|
+
url = {https://github.com/pedramezani/charite-plot},
|
|
158
|
+
license = {MIT},
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Acknowledgements
|
|
163
|
+
|
|
164
|
+
This package is based on the original [`charite` R package](https://github.com/johannesjuliusm/charite) developed by Johannes Julius Mohn.
|
|
165
|
+
|
|
139
166
|
## License
|
|
140
167
|
|
|
141
168
|
MIT © 2026 Pedram Ramezani
|
|
169
|
+
|
|
170
|
+
The original `charite` R package by Johannes Julius Mohn is likewise MIT licensed.
|
|
@@ -14,13 +14,13 @@ pip install "charite-plot[altair]" # with Altair support
|
|
|
14
14
|
Visualize your data with `theme_charite()` to match the Charité corporate style.
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
|
-
<img src="docs/assets/theme_example.png" width="80%"/>
|
|
17
|
+
<img src="https://raw.githubusercontent.com/pedramezani/charite-plot/main/docs/assets/theme_example.png" width="80%"/>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
20
|
Preview the available colour palettes.
|
|
21
21
|
|
|
22
22
|
<p align="center">
|
|
23
|
-
<img src="docs/assets/palette_preview.png" width="80%"/>
|
|
23
|
+
<img src="https://raw.githubusercontent.com/pedramezani/charite-plot/main/docs/assets/palette_preview.png" width="80%"/>
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
## Quick start
|
|
@@ -83,16 +83,35 @@ enable(palette="berryseason", font_size=13)
|
|
|
83
83
|
|
|
84
84
|
The fallback chain follows the official Charité brand guidelines:
|
|
85
85
|
|
|
86
|
-
**Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans**
|
|
86
|
+
**Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans → sans-serif**
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
`DejaVu Sans` ships with Matplotlib and is always available as the final fallback. To override the preferred font:
|
|
88
|
+
`DejaVu Sans` ships with Matplotlib and is always available as the penultimate fallback; `sans-serif` lets the browser or system choose if nothing else matches (important for Altair/Vega-Lite). To override the preferred font:
|
|
91
89
|
|
|
92
90
|
```python
|
|
93
91
|
apply_theme(theme_charite(font="Arial"))
|
|
94
92
|
```
|
|
95
93
|
|
|
94
|
+
## How to cite
|
|
95
|
+
|
|
96
|
+
If you use charite-plot in your work, please cite it as:
|
|
97
|
+
|
|
98
|
+
```bibtex
|
|
99
|
+
@software{ramezani2026chariteplot,
|
|
100
|
+
author = {Ramezani, Pedram},
|
|
101
|
+
title = {charite-plot: Matplotlib and Altair Themes for Charité – Universitätsmedizin Berlin},
|
|
102
|
+
year = {2026},
|
|
103
|
+
version = {0.2.0},
|
|
104
|
+
url = {https://github.com/pedramezani/charite-plot},
|
|
105
|
+
license = {MIT},
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Acknowledgements
|
|
110
|
+
|
|
111
|
+
This package is based on the original [`charite` R package](https://github.com/johannesjuliusm/charite) developed by Johannes Julius Mohn.
|
|
112
|
+
|
|
96
113
|
## License
|
|
97
114
|
|
|
98
115
|
MIT © 2026 Pedram Ramezani
|
|
116
|
+
|
|
117
|
+
The original `charite` R package by Johannes Julius Mohn is likewise MIT licensed.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Shared theme primitives for the matplotlib and Altair backends.
|
|
2
|
+
|
|
3
|
+
These small ``NamedTuple`` structures keep the per-backend theme builders
|
|
4
|
+
readable by giving names to the derived size/margin values. The font-size
|
|
5
|
+
ratios are shared so both backends scale identically from their base size
|
|
6
|
+
(matplotlib works in points, Altair in pixels, but the ratios are the same).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from typing import NamedTuple
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FontSizes(NamedTuple):
|
|
13
|
+
"""Derived font sizes, all scaled from the base ``font_size``."""
|
|
14
|
+
title: float
|
|
15
|
+
subtitle: float
|
|
16
|
+
label: float
|
|
17
|
+
legend: float
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class Margins(NamedTuple):
|
|
21
|
+
"""Derived margins/paddings around the plot panel.
|
|
22
|
+
|
|
23
|
+
``wspace`` / ``hspace`` are subplot-spacing fractions used only by the
|
|
24
|
+
matplotlib backend; they default to ``0`` so the Altair backend can build
|
|
25
|
+
a ``Margins`` without supplying them.
|
|
26
|
+
"""
|
|
27
|
+
title: float
|
|
28
|
+
label: float
|
|
29
|
+
legend: float
|
|
30
|
+
wspace: float = 0.0
|
|
31
|
+
hspace: float = 0.0
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class Thickness(NamedTuple):
|
|
35
|
+
"""Derived line widths, scaled from the base ``thickness``.
|
|
36
|
+
|
|
37
|
+
``lines`` / ``patches`` are matplotlib-specific defaults; they carry
|
|
38
|
+
defaults so the Altair backend can build a ``Thickness`` from just the
|
|
39
|
+
axis-related widths.
|
|
40
|
+
"""
|
|
41
|
+
axes: float
|
|
42
|
+
grid: float
|
|
43
|
+
ticks: float
|
|
44
|
+
lines: float = 1.5
|
|
45
|
+
patches: float = 0.0
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def resolve_font_sizes(font_size: float) -> FontSizes:
|
|
49
|
+
"""Return the standard Charité font-size ramp derived from *font_size*."""
|
|
50
|
+
return FontSizes(
|
|
51
|
+
title=round(font_size * 1.2),
|
|
52
|
+
subtitle=font_size,
|
|
53
|
+
label=font_size,
|
|
54
|
+
legend=round(font_size * 0.8),
|
|
55
|
+
)
|
|
@@ -8,17 +8,20 @@ Register and enable with::
|
|
|
8
8
|
enable(font="Arial", font_size=13) # font override
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
11
13
|
from .colors import (
|
|
12
14
|
BLACK, WHITE, TEXT_GREY, PRIME_BLUE, PRIME_LGREY,
|
|
13
15
|
SECOND_DBLUE, KORALL,
|
|
14
16
|
)
|
|
15
17
|
from .palettes import PALETTES
|
|
16
18
|
from .fonts import build_font_stack
|
|
19
|
+
from ._theme_common import Margins, Thickness, resolve_font_sizes
|
|
17
20
|
|
|
18
21
|
from typing import TYPE_CHECKING
|
|
19
22
|
|
|
20
23
|
if TYPE_CHECKING:
|
|
21
|
-
from altair.theme import ThemeConfig
|
|
24
|
+
from altair.theme import AxisConfigKwds, ThemeConfig
|
|
22
25
|
|
|
23
26
|
|
|
24
27
|
def _css_font_stack(preferred: str | None) -> str:
|
|
@@ -32,90 +35,109 @@ def _css_font_stack(preferred: str | None) -> str:
|
|
|
32
35
|
def theme_charite(
|
|
33
36
|
font: str | None = None,
|
|
34
37
|
font_size: int = 12,
|
|
38
|
+
thickness: float = 0.5,
|
|
35
39
|
grid: bool = False,
|
|
36
40
|
palette: str | list[str] = "primary",
|
|
37
41
|
background: str = "white",
|
|
38
|
-
|
|
42
|
+
tiny_margins: bool = False,
|
|
43
|
+
) -> ThemeConfig:
|
|
39
44
|
"""Return an Altair theme config dict for the Charité corporate theme.
|
|
40
45
|
|
|
41
46
|
Parameters
|
|
42
47
|
----------
|
|
43
48
|
font:
|
|
44
|
-
Preferred font. Falls back through Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans.
|
|
49
|
+
Preferred font. Falls back through Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans → sans-serif.
|
|
45
50
|
font_size:
|
|
46
51
|
Base font size in pixels.
|
|
52
|
+
thickness:
|
|
53
|
+
Axis line and tick width.
|
|
47
54
|
grid:
|
|
48
55
|
Show axis grid lines.
|
|
49
56
|
palette:
|
|
50
57
|
Built-in palette name or list of hex colors for the categorical range.
|
|
51
58
|
background:
|
|
52
59
|
Chart background color.
|
|
60
|
+
tiny_margins:
|
|
61
|
+
Minimise all paddings around the chart.
|
|
53
62
|
"""
|
|
54
63
|
colors = PALETTES[palette] if isinstance(palette, str) else list(palette)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
font_stack = _css_font_stack(preferred=font)
|
|
65
|
+
|
|
66
|
+
FONT_SIZES = resolve_font_sizes(font_size)
|
|
67
|
+
MARGINS = Margins(
|
|
68
|
+
title=8 if tiny_margins else 12, # chart title offset
|
|
69
|
+
label=3 if tiny_margins else 6, # axis / legend title padding
|
|
70
|
+
legend=2 if tiny_margins else 4, # legend inner padding
|
|
71
|
+
)
|
|
72
|
+
THICKNESS = Thickness(
|
|
73
|
+
axes=thickness, # domain line width
|
|
74
|
+
grid=thickness * 0.8, # grid line width
|
|
75
|
+
ticks=thickness, # tick mark width
|
|
76
|
+
lines=2, # line-mark stroke width (independent of thickness)
|
|
77
|
+
patches=0.4, # geoshape stroke width
|
|
78
|
+
)
|
|
79
|
+
CHART_PAD = 6 if tiny_margins else 10
|
|
80
|
+
|
|
81
|
+
axis: AxisConfigKwds = {
|
|
82
|
+
"labelFont": font_stack,
|
|
83
|
+
"titleFont": font_stack,
|
|
84
|
+
"labelFontSize": FONT_SIZES.label,
|
|
85
|
+
"titleFontSize": FONT_SIZES.subtitle,
|
|
64
86
|
"labelColor": TEXT_GREY,
|
|
65
87
|
"titleColor": TEXT_GREY,
|
|
66
|
-
"titlePadding":
|
|
88
|
+
"titlePadding": MARGINS.label,
|
|
67
89
|
"domain": True,
|
|
68
90
|
"domainColor": BLACK,
|
|
69
|
-
"domainWidth":
|
|
91
|
+
"domainWidth": THICKNESS.axes,
|
|
70
92
|
"ticks": True,
|
|
71
93
|
"tickColor": BLACK,
|
|
72
|
-
"tickWidth":
|
|
94
|
+
"tickWidth": THICKNESS.ticks,
|
|
73
95
|
"tickSize": 4,
|
|
74
96
|
"grid": grid,
|
|
75
97
|
"gridColor": PRIME_LGREY,
|
|
76
|
-
"gridWidth":
|
|
77
|
-
"gridOpacity": 0.
|
|
98
|
+
"gridWidth": THICKNESS.grid,
|
|
99
|
+
"gridOpacity": 0.85,
|
|
78
100
|
}
|
|
79
101
|
|
|
80
102
|
return {
|
|
81
103
|
"config": {
|
|
82
104
|
"background": background,
|
|
83
|
-
"font":
|
|
84
|
-
"padding": {"top":
|
|
105
|
+
"font": font_stack,
|
|
106
|
+
"padding": {"top": CHART_PAD, "bottom": CHART_PAD, "left": CHART_PAD, "right": CHART_PAD},
|
|
85
107
|
"view": {"stroke": None},
|
|
86
108
|
"axis": axis,
|
|
87
109
|
"axisX": axis,
|
|
88
110
|
"axisY": axis,
|
|
89
111
|
"legend": {
|
|
90
|
-
"labelFont":
|
|
91
|
-
"titleFont":
|
|
92
|
-
"labelFontSize":
|
|
93
|
-
"titleFontSize":
|
|
112
|
+
"labelFont": font_stack,
|
|
113
|
+
"titleFont": font_stack,
|
|
114
|
+
"labelFontSize": FONT_SIZES.legend,
|
|
115
|
+
"titleFontSize": FONT_SIZES.subtitle,
|
|
94
116
|
"labelColor": TEXT_GREY,
|
|
95
117
|
"titleColor": TEXT_GREY,
|
|
96
|
-
"titlePadding":
|
|
97
|
-
"padding":
|
|
98
|
-
"rowPadding":
|
|
118
|
+
"titlePadding": MARGINS.label,
|
|
119
|
+
"padding": MARGINS.legend,
|
|
120
|
+
"rowPadding": FONT_SIZES.legend / 4,
|
|
99
121
|
"symbolSize": 100,
|
|
100
122
|
},
|
|
101
123
|
"header": {
|
|
102
|
-
"labelFont":
|
|
103
|
-
"titleFont":
|
|
104
|
-
"labelFontSize":
|
|
105
|
-
"titleFontSize":
|
|
124
|
+
"labelFont": font_stack,
|
|
125
|
+
"titleFont": font_stack,
|
|
126
|
+
"labelFontSize": FONT_SIZES.label,
|
|
127
|
+
"titleFontSize": FONT_SIZES.subtitle,
|
|
106
128
|
"labelColor": WHITE,
|
|
107
129
|
"titleColor": PRIME_BLUE,
|
|
108
130
|
"labelBackground": PRIME_BLUE,
|
|
109
131
|
},
|
|
110
132
|
"title": {
|
|
111
|
-
"font":
|
|
112
|
-
"subtitleFont":
|
|
113
|
-
"fontSize":
|
|
114
|
-
"subtitleFontSize":
|
|
133
|
+
"font": font_stack,
|
|
134
|
+
"subtitleFont": font_stack,
|
|
135
|
+
"fontSize": FONT_SIZES.title,
|
|
136
|
+
"subtitleFontSize": FONT_SIZES.subtitle,
|
|
115
137
|
"color": PRIME_BLUE,
|
|
116
138
|
"subtitleColor": TEXT_GREY,
|
|
117
139
|
"anchor": "middle",
|
|
118
|
-
"offset":
|
|
140
|
+
"offset": MARGINS.title,
|
|
119
141
|
},
|
|
120
142
|
"range": {
|
|
121
143
|
"category": colors,
|
|
@@ -125,13 +147,13 @@ def theme_charite(
|
|
|
125
147
|
"ramp": ["#ffffff", PRIME_BLUE],
|
|
126
148
|
},
|
|
127
149
|
"bar": {"color": colors[0], "binSpacing": 1},
|
|
128
|
-
"line": {"color": colors[0], "strokeWidth":
|
|
150
|
+
"line": {"color": colors[0], "strokeWidth": THICKNESS.lines},
|
|
129
151
|
"point": {"color": colors[0], "size": 60, "opacity": 0.85, "filled": True},
|
|
130
152
|
"area": {"color": colors[0], "opacity": 0.8},
|
|
131
153
|
"arc": {"color": colors[0]},
|
|
132
154
|
"rect": {"color": colors[0]},
|
|
133
|
-
"geoshape": {"stroke": WHITE, "strokeWidth":
|
|
134
|
-
"text": {"font":
|
|
155
|
+
"geoshape": {"stroke": WHITE, "strokeWidth": THICKNESS.patches},
|
|
156
|
+
"text": {"font": font_stack, "fontSize": FONT_SIZES.label, "color": TEXT_GREY},
|
|
135
157
|
}
|
|
136
158
|
}
|
|
137
159
|
|
|
@@ -149,7 +171,8 @@ def enable(**kwargs) -> None:
|
|
|
149
171
|
----------
|
|
150
172
|
**kwargs:
|
|
151
173
|
Any parameter accepted by ``theme_charite``
|
|
152
|
-
(``font``, ``font_size``, ``grid``, ``palette``,
|
|
174
|
+
(``font``, ``font_size``, ``thickness``, ``grid``, ``palette``,
|
|
175
|
+
``background``, ``tiny_margins``).
|
|
153
176
|
|
|
154
177
|
Examples
|
|
155
178
|
--------
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import warnings
|
|
4
4
|
|
|
5
|
-
FONT_STACK = ["Charité Text Office", "Charit? Text Office", "Calibri", "DejaVu Sans"]
|
|
5
|
+
FONT_STACK = ["Charité Text Office", "Charit? Text Office", "Calibri", "DejaVu Sans", "sans-serif"]
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
def _available_fonts() -> set[str]:
|
|
@@ -19,7 +19,7 @@ def check_font(font: str) -> bool:
|
|
|
19
19
|
return True
|
|
20
20
|
warnings.warn(
|
|
21
21
|
f"Font '{font}' is not installed on this system. "
|
|
22
|
-
"Using the fallback chain: Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans.",
|
|
22
|
+
"Using the fallback chain: Charité Text Office → Charit? Text Office → Calibri → DejaVu Sans → sans-serif.",
|
|
23
23
|
UserWarning,
|
|
24
24
|
stacklevel=3,
|
|
25
25
|
)
|