mintfig 0.2.0__py3-none-any.whl
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.
- mintfig/__init__.py +162 -0
- mintfig/_explain/__init__.py +1 -0
- mintfig/_explain/change.py +392 -0
- mintfig/_explain/compare.py +1308 -0
- mintfig/_explain/compare_grouped.py +472 -0
- mintfig/_explain/core.py +2005 -0
- mintfig/_explain/distribution.py +1268 -0
- mintfig/_explain/flow.py +508 -0
- mintfig/_explain/layout.py +2012 -0
- mintfig/_explain/matrix.py +623 -0
- mintfig/_explain/relate.py +1318 -0
- mintfig/_explain/timeline.py +595 -0
- mintfig/_explain/trend.py +2557 -0
- mintfig/_explain/waterfall.py +459 -0
- mintfig/_table.py +691 -0
- mintfig/_tabular.py +738 -0
- mintfig/annotations.py +1165 -0
- mintfig/assets/AGENTS_SNIPPET.md +11 -0
- mintfig/assets/SKILL.md +143 -0
- mintfig/assets/__init__.py +1 -0
- mintfig/assets/references/publication.md +79 -0
- mintfig/assets/references/scientific_and_recipes.md +213 -0
- mintfig/audit.py +179 -0
- mintfig/brief.py +518 -0
- mintfig/bundle.py +333 -0
- mintfig/cli.py +1300 -0
- mintfig/edit.py +347 -0
- mintfig/epistemic.py +1083 -0
- mintfig/explainer.py +194 -0
- mintfig/export.py +247 -0
- mintfig/inspect_data.py +583 -0
- mintfig/interactive.py +1028 -0
- mintfig/palettes.py +233 -0
- mintfig/plate.py +784 -0
- mintfig/preflight.py +2398 -0
- mintfig/proof.py +627 -0
- mintfig/runner.py +403 -0
- mintfig/skill.py +167 -0
- mintfig/specs.py +291 -0
- mintfig/style.py +151 -0
- mintfig/terminal.py +785 -0
- mintfig/themes.py +660 -0
- mintfig-0.2.0.dist-info/METADATA +239 -0
- mintfig-0.2.0.dist-info/RECORD +47 -0
- mintfig-0.2.0.dist-info/WHEEL +4 -0
- mintfig-0.2.0.dist-info/entry_points.txt +2 -0
- mintfig-0.2.0.dist-info/licenses/LICENSE +21 -0
mintfig/specs.py
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"""Journal physical specifications for publication-ready scientific figures."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from typing import Literal
|
|
8
|
+
|
|
9
|
+
MM_PER_INCH: float = 25.4
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def mm_to_in(mm: float) -> float:
|
|
13
|
+
"""Convert millimeters to inches."""
|
|
14
|
+
return float(mm) / MM_PER_INCH
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def in_to_mm(inches: float) -> float:
|
|
18
|
+
"""Convert inches to millimeters."""
|
|
19
|
+
return float(inches) * MM_PER_INCH
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass(frozen=True)
|
|
23
|
+
class JournalSpec:
|
|
24
|
+
"""Immutable physical, typographic, and export specification for a journal."""
|
|
25
|
+
|
|
26
|
+
name: str
|
|
27
|
+
display_name: str
|
|
28
|
+
widths_mm: dict[str, float]
|
|
29
|
+
max_height_mm: float
|
|
30
|
+
max_page_height_mm: float
|
|
31
|
+
font_family: tuple[str, ...]
|
|
32
|
+
font_min_pt: float
|
|
33
|
+
font_max_pt: float
|
|
34
|
+
body_pt: float
|
|
35
|
+
tick_pt: float
|
|
36
|
+
legend_pt: float
|
|
37
|
+
panel_label_pt: float
|
|
38
|
+
panel_label_case: Literal["lower", "upper"]
|
|
39
|
+
panel_label_weight: str = "bold"
|
|
40
|
+
axes_linewidth_pt: float = 0.5
|
|
41
|
+
data_linewidth_pt: float = 0.9
|
|
42
|
+
min_linewidth_pt: float = 0.25
|
|
43
|
+
tick_length_pt: float = 2.5
|
|
44
|
+
dpi_photo: int = 300
|
|
45
|
+
dpi_combo: int = 500
|
|
46
|
+
dpi_line: int = 1000
|
|
47
|
+
default_palette: str = "nature"
|
|
48
|
+
# Empty by default so custom JournalSpec instances do not inherit a
|
|
49
|
+
# verification or version claim from built-in publisher presets.
|
|
50
|
+
spec_version: str = ""
|
|
51
|
+
# ISO date the spec was last checked against the publisher's guidelines;
|
|
52
|
+
# empty means unverified (custom specs must not inherit a verification claim).
|
|
53
|
+
last_verified: str = ""
|
|
54
|
+
source_url: str = ""
|
|
55
|
+
|
|
56
|
+
def resolve_width_mm(self, width: str | float) -> float:
|
|
57
|
+
"""Resolve a column preset name or explicit positive millimeter width."""
|
|
58
|
+
if isinstance(width, str):
|
|
59
|
+
key = width.strip().lower()
|
|
60
|
+
lookup = {k.lower(): v for k, v in self.widths_mm.items()}
|
|
61
|
+
if key not in lookup:
|
|
62
|
+
valid = ", ".join(sorted(self.widths_mm.keys()))
|
|
63
|
+
raise ValueError(
|
|
64
|
+
f"Unknown width preset {width!r} for {self.display_name}. "
|
|
65
|
+
f"Valid presets: {valid}"
|
|
66
|
+
)
|
|
67
|
+
return float(lookup[key])
|
|
68
|
+
if isinstance(width, bool) or not isinstance(width, (int, float)):
|
|
69
|
+
raise TypeError(
|
|
70
|
+
f"width must be a preset name (str) or positive float in mm, got {type(width).__name__}"
|
|
71
|
+
)
|
|
72
|
+
val = float(width)
|
|
73
|
+
if not math.isfinite(val) or val <= 0.0:
|
|
74
|
+
raise ValueError(f"width must be a finite positive number in mm, got {width!r}")
|
|
75
|
+
return val
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
JOURNALS: dict[str, JournalSpec] = {
|
|
79
|
+
"nature": JournalSpec(
|
|
80
|
+
name="nature",
|
|
81
|
+
display_name="Nature Portfolio",
|
|
82
|
+
widths_mm={
|
|
83
|
+
"single": 89.0,
|
|
84
|
+
"mid": 120.0,
|
|
85
|
+
"1.5col": 120.0,
|
|
86
|
+
"double": 183.0,
|
|
87
|
+
"full": 183.0,
|
|
88
|
+
},
|
|
89
|
+
max_height_mm=170.0,
|
|
90
|
+
max_page_height_mm=247.0,
|
|
91
|
+
font_family=("Helvetica", "Arial", "Liberation Sans", "DejaVu Sans"),
|
|
92
|
+
font_min_pt=5.0,
|
|
93
|
+
font_max_pt=7.0,
|
|
94
|
+
body_pt=6.5,
|
|
95
|
+
tick_pt=6.0,
|
|
96
|
+
legend_pt=6.0,
|
|
97
|
+
panel_label_pt=8.0,
|
|
98
|
+
panel_label_case="lower",
|
|
99
|
+
dpi_photo=300,
|
|
100
|
+
dpi_combo=500,
|
|
101
|
+
dpi_line=1000,
|
|
102
|
+
default_palette="nature",
|
|
103
|
+
spec_version="2025.1",
|
|
104
|
+
last_verified="2026-11-23",
|
|
105
|
+
source_url="https://www.nature.com/nature/for-authors/final-submission",
|
|
106
|
+
),
|
|
107
|
+
"science": JournalSpec(
|
|
108
|
+
name="science",
|
|
109
|
+
display_name="Science (AAAS)",
|
|
110
|
+
widths_mm={
|
|
111
|
+
"single": 55.0,
|
|
112
|
+
"double": 120.0,
|
|
113
|
+
"2col": 120.0,
|
|
114
|
+
"full": 184.0,
|
|
115
|
+
"3col": 184.0,
|
|
116
|
+
},
|
|
117
|
+
max_height_mm=180.0,
|
|
118
|
+
max_page_height_mm=230.0,
|
|
119
|
+
font_family=("Helvetica", "Arial", "Liberation Sans", "DejaVu Sans"),
|
|
120
|
+
font_min_pt=6.0,
|
|
121
|
+
font_max_pt=8.0,
|
|
122
|
+
body_pt=7.0,
|
|
123
|
+
tick_pt=6.0,
|
|
124
|
+
legend_pt=6.5,
|
|
125
|
+
panel_label_pt=8.5,
|
|
126
|
+
panel_label_case="upper",
|
|
127
|
+
dpi_photo=300,
|
|
128
|
+
dpi_combo=600,
|
|
129
|
+
dpi_line=1200,
|
|
130
|
+
default_palette="science",
|
|
131
|
+
spec_version="2025.1",
|
|
132
|
+
last_verified="2026-11-23",
|
|
133
|
+
source_url="https://www.science.org/content/page/instructions-preparing-revised-manuscript",
|
|
134
|
+
),
|
|
135
|
+
"science_advances": JournalSpec(
|
|
136
|
+
name="science_advances",
|
|
137
|
+
display_name="Science Advances",
|
|
138
|
+
widths_mm={
|
|
139
|
+
"single": 84.0,
|
|
140
|
+
"mid": 120.0,
|
|
141
|
+
"double": 175.0,
|
|
142
|
+
"full": 175.0,
|
|
143
|
+
},
|
|
144
|
+
max_height_mm=180.0,
|
|
145
|
+
max_page_height_mm=230.0,
|
|
146
|
+
font_family=("Helvetica", "Arial", "Liberation Sans", "DejaVu Sans"),
|
|
147
|
+
font_min_pt=6.0,
|
|
148
|
+
font_max_pt=8.0,
|
|
149
|
+
body_pt=7.0,
|
|
150
|
+
tick_pt=6.0,
|
|
151
|
+
legend_pt=6.5,
|
|
152
|
+
panel_label_pt=8.5,
|
|
153
|
+
panel_label_case="upper",
|
|
154
|
+
dpi_photo=300,
|
|
155
|
+
dpi_combo=600,
|
|
156
|
+
dpi_line=1200,
|
|
157
|
+
default_palette="science",
|
|
158
|
+
spec_version="2025.1",
|
|
159
|
+
last_verified="2026-11-23",
|
|
160
|
+
source_url="https://www.science.org/content/page/science-advances-information-authors",
|
|
161
|
+
),
|
|
162
|
+
"cell": JournalSpec(
|
|
163
|
+
name="cell",
|
|
164
|
+
display_name="Cell Press",
|
|
165
|
+
widths_mm={
|
|
166
|
+
"single": 85.0,
|
|
167
|
+
"mid": 114.0,
|
|
168
|
+
"1.5col": 114.0,
|
|
169
|
+
"double": 174.0,
|
|
170
|
+
"full": 174.0,
|
|
171
|
+
},
|
|
172
|
+
max_height_mm=200.0,
|
|
173
|
+
max_page_height_mm=230.0,
|
|
174
|
+
font_family=("Helvetica", "Arial", "Liberation Sans", "DejaVu Sans"),
|
|
175
|
+
font_min_pt=6.0,
|
|
176
|
+
font_max_pt=8.0,
|
|
177
|
+
body_pt=7.0,
|
|
178
|
+
tick_pt=6.0,
|
|
179
|
+
legend_pt=6.5,
|
|
180
|
+
panel_label_pt=8.5,
|
|
181
|
+
panel_label_case="upper",
|
|
182
|
+
dpi_photo=300,
|
|
183
|
+
dpi_combo=500,
|
|
184
|
+
dpi_line=1000,
|
|
185
|
+
default_palette="nature_muted",
|
|
186
|
+
spec_version="2025.1",
|
|
187
|
+
last_verified="2026-11-23",
|
|
188
|
+
source_url="https://www.cell.com/figureguidelines",
|
|
189
|
+
),
|
|
190
|
+
"pnas": JournalSpec(
|
|
191
|
+
name="pnas",
|
|
192
|
+
display_name="PNAS",
|
|
193
|
+
widths_mm={
|
|
194
|
+
"single": 87.0,
|
|
195
|
+
"mid": 114.0,
|
|
196
|
+
"1.5col": 114.0,
|
|
197
|
+
"double": 178.0,
|
|
198
|
+
"full": 178.0,
|
|
199
|
+
},
|
|
200
|
+
max_height_mm=200.0,
|
|
201
|
+
max_page_height_mm=225.0,
|
|
202
|
+
font_family=("Helvetica", "Arial", "Liberation Sans", "DejaVu Sans"),
|
|
203
|
+
font_min_pt=6.0,
|
|
204
|
+
font_max_pt=10.0,
|
|
205
|
+
body_pt=7.0,
|
|
206
|
+
tick_pt=6.5,
|
|
207
|
+
legend_pt=6.5,
|
|
208
|
+
panel_label_pt=9.0,
|
|
209
|
+
panel_label_case="upper",
|
|
210
|
+
dpi_photo=300,
|
|
211
|
+
dpi_combo=600,
|
|
212
|
+
dpi_line=1200,
|
|
213
|
+
default_palette="nature_muted",
|
|
214
|
+
spec_version="2025.1",
|
|
215
|
+
last_verified="2026-11-23",
|
|
216
|
+
source_url="https://www.pnas.org/author-center/submitting-your-manuscript",
|
|
217
|
+
),
|
|
218
|
+
"neurips": JournalSpec(
|
|
219
|
+
name="neurips",
|
|
220
|
+
display_name="NeurIPS",
|
|
221
|
+
widths_mm={
|
|
222
|
+
"half": 67.0,
|
|
223
|
+
"single": 67.0,
|
|
224
|
+
"mid": 111.8,
|
|
225
|
+
"double": 139.7,
|
|
226
|
+
"full": 139.7,
|
|
227
|
+
},
|
|
228
|
+
max_height_mm=180.0,
|
|
229
|
+
max_page_height_mm=228.6,
|
|
230
|
+
font_family=("Helvetica", "Arial", "Liberation Sans", "DejaVu Sans"),
|
|
231
|
+
font_min_pt=6.0,
|
|
232
|
+
font_max_pt=10.0,
|
|
233
|
+
body_pt=7.5,
|
|
234
|
+
tick_pt=6.5,
|
|
235
|
+
legend_pt=6.5,
|
|
236
|
+
panel_label_pt=8.5,
|
|
237
|
+
panel_label_case="lower",
|
|
238
|
+
dpi_photo=300,
|
|
239
|
+
dpi_combo=500,
|
|
240
|
+
dpi_line=1000,
|
|
241
|
+
default_palette="nature_muted",
|
|
242
|
+
spec_version="2025.1",
|
|
243
|
+
last_verified="2026-11-23",
|
|
244
|
+
source_url="https://neurips.cc/Conferences/2025/PaperInformation/StyleFiles",
|
|
245
|
+
),
|
|
246
|
+
"screen": JournalSpec(
|
|
247
|
+
name="screen",
|
|
248
|
+
display_name="Screen / Chat Review",
|
|
249
|
+
widths_mm={
|
|
250
|
+
"narrow": 92.0,
|
|
251
|
+
"chat": 140.0,
|
|
252
|
+
"single": 140.0,
|
|
253
|
+
"wide": 180.0,
|
|
254
|
+
"double": 180.0,
|
|
255
|
+
"full": 180.0,
|
|
256
|
+
"slide": 240.0,
|
|
257
|
+
},
|
|
258
|
+
max_height_mm=135.0,
|
|
259
|
+
max_page_height_mm=160.0,
|
|
260
|
+
font_family=("Helvetica", "Arial", "Liberation Sans", "DejaVu Sans"),
|
|
261
|
+
font_min_pt=7.0,
|
|
262
|
+
font_max_pt=12.0,
|
|
263
|
+
body_pt=8.5,
|
|
264
|
+
tick_pt=7.5,
|
|
265
|
+
legend_pt=7.5,
|
|
266
|
+
panel_label_pt=10.0,
|
|
267
|
+
panel_label_case="lower",
|
|
268
|
+
axes_linewidth_pt=0.6,
|
|
269
|
+
data_linewidth_pt=1.2,
|
|
270
|
+
dpi_photo=200,
|
|
271
|
+
dpi_combo=220,
|
|
272
|
+
dpi_line=300,
|
|
273
|
+
default_palette="nature_muted",
|
|
274
|
+
spec_version="0.3",
|
|
275
|
+
last_verified="2026-11-23",
|
|
276
|
+
source_url="",
|
|
277
|
+
),
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def get_spec(journal: str | JournalSpec) -> JournalSpec:
|
|
282
|
+
"""Return a JournalSpec from a journal identifier or pass through an existing spec."""
|
|
283
|
+
if isinstance(journal, JournalSpec):
|
|
284
|
+
return journal
|
|
285
|
+
if not isinstance(journal, str):
|
|
286
|
+
raise TypeError(f"journal must be a str or JournalSpec, got {type(journal).__name__}")
|
|
287
|
+
key = journal.strip().lower().replace("-", "_").replace(" ", "_")
|
|
288
|
+
if key not in JOURNALS:
|
|
289
|
+
valid = ", ".join(sorted(JOURNALS.keys()))
|
|
290
|
+
raise ValueError(f"Unknown journal {journal!r}. Available journals: {valid}")
|
|
291
|
+
return JOURNALS[key]
|
mintfig/style.py
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"""Publication-grade Matplotlib styling and font resolution for Nature & Science."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from contextlib import AbstractContextManager
|
|
6
|
+
from functools import lru_cache
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
import matplotlib as mpl
|
|
10
|
+
from cycler import cycler
|
|
11
|
+
from matplotlib import font_manager
|
|
12
|
+
|
|
13
|
+
from .palettes import get_palette
|
|
14
|
+
from .specs import JournalSpec, get_spec
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@lru_cache(maxsize=16)
|
|
18
|
+
def _resolve_font_tuple(families: tuple[str, ...]) -> str:
|
|
19
|
+
"""Return the first installed font family name from ``families``."""
|
|
20
|
+
installed = {entry.name.lower(): entry.name for entry in font_manager.fontManager.ttflist}
|
|
21
|
+
for candidate in families:
|
|
22
|
+
key = candidate.lower()
|
|
23
|
+
if key in installed:
|
|
24
|
+
return installed[key]
|
|
25
|
+
for candidate in families:
|
|
26
|
+
try:
|
|
27
|
+
fp = font_manager.FontProperties(family=candidate)
|
|
28
|
+
found_path = font_manager.findfont(fp, fallback_to_default=False)
|
|
29
|
+
if found_path:
|
|
30
|
+
return candidate
|
|
31
|
+
except ValueError:
|
|
32
|
+
continue
|
|
33
|
+
return "DejaVu Sans"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def resolved_font_name(spec: str | JournalSpec = "nature") -> str:
|
|
37
|
+
"""Detect the first installed sans-serif font from ``spec.font_family``."""
|
|
38
|
+
resolved_spec = get_spec(spec)
|
|
39
|
+
return _resolve_font_tuple(resolved_spec.font_family)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def rc_params(
|
|
43
|
+
journal: str | JournalSpec = "nature",
|
|
44
|
+
*,
|
|
45
|
+
palette: str | None = None,
|
|
46
|
+
) -> dict[str, Any]:
|
|
47
|
+
"""Build a Matplotlib rcParams dictionary conforming to ``journal`` specs."""
|
|
48
|
+
spec = get_spec(journal)
|
|
49
|
+
colors = get_palette(palette if palette is not None else spec.default_palette)
|
|
50
|
+
font_name = resolved_font_name(spec)
|
|
51
|
+
minor_tick_w = max(spec.min_linewidth_pt, round(spec.axes_linewidth_pt * 0.75, 3))
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
# Editable vector font embedding (TrueType Type 42 in PDF/PS, raw text in SVG)
|
|
55
|
+
"pdf.fonttype": 42,
|
|
56
|
+
"ps.fonttype": 42,
|
|
57
|
+
"svg.fonttype": "none",
|
|
58
|
+
# Typography (uniform sans-serif body + math)
|
|
59
|
+
"font.family": "sans-serif",
|
|
60
|
+
"font.sans-serif": list(spec.font_family),
|
|
61
|
+
"font.size": spec.body_pt,
|
|
62
|
+
"text.color": "#1A1D21",
|
|
63
|
+
"mathtext.fontset": "custom",
|
|
64
|
+
"mathtext.rm": font_name,
|
|
65
|
+
"mathtext.it": f"{font_name}:italic",
|
|
66
|
+
"mathtext.bf": f"{font_name}:bold",
|
|
67
|
+
"mathtext.sf": font_name,
|
|
68
|
+
# Variables render italic ($T$, $P$, $\rho$) while explicit \mathrm{...} stays upright.
|
|
69
|
+
"mathtext.default": "it",
|
|
70
|
+
"mathtext.fallback": "stixsans",
|
|
71
|
+
"axes.unicode_minus": True,
|
|
72
|
+
# Axes & spines
|
|
73
|
+
"axes.spines.top": False,
|
|
74
|
+
"axes.spines.right": False,
|
|
75
|
+
"axes.linewidth": spec.axes_linewidth_pt,
|
|
76
|
+
"axes.edgecolor": "#2B3036",
|
|
77
|
+
"axes.labelcolor": "#1A1D21",
|
|
78
|
+
"axes.labelsize": spec.body_pt,
|
|
79
|
+
"axes.labelpad": 3.5,
|
|
80
|
+
"axes.titlesize": spec.body_pt,
|
|
81
|
+
"axes.titlepad": 5.5,
|
|
82
|
+
"axes.titleweight": "normal",
|
|
83
|
+
"axes.axisbelow": True,
|
|
84
|
+
"axes.grid": False,
|
|
85
|
+
"axes.prop_cycle": cycler(color=colors),
|
|
86
|
+
# Crisp outward ticks
|
|
87
|
+
"xtick.direction": "out",
|
|
88
|
+
"ytick.direction": "out",
|
|
89
|
+
"xtick.top": False,
|
|
90
|
+
"ytick.right": False,
|
|
91
|
+
"xtick.color": "#2B3036",
|
|
92
|
+
"ytick.color": "#2B3036",
|
|
93
|
+
"xtick.major.width": spec.axes_linewidth_pt,
|
|
94
|
+
"ytick.major.width": spec.axes_linewidth_pt,
|
|
95
|
+
"xtick.minor.width": minor_tick_w,
|
|
96
|
+
"ytick.minor.width": minor_tick_w,
|
|
97
|
+
"xtick.major.size": 2.2,
|
|
98
|
+
"ytick.major.size": 2.2,
|
|
99
|
+
"xtick.minor.size": 1.3,
|
|
100
|
+
"ytick.minor.size": 1.3,
|
|
101
|
+
"xtick.major.pad": 2.5,
|
|
102
|
+
"ytick.major.pad": 2.5,
|
|
103
|
+
"xtick.labelsize": spec.tick_pt,
|
|
104
|
+
"ytick.labelsize": spec.tick_pt,
|
|
105
|
+
# Clean frameless legends
|
|
106
|
+
"legend.frameon": False,
|
|
107
|
+
"legend.fontsize": spec.legend_pt,
|
|
108
|
+
"legend.title_fontsize": spec.legend_pt,
|
|
109
|
+
"legend.handlelength": 1.4,
|
|
110
|
+
"legend.handletextpad": 0.5,
|
|
111
|
+
"legend.borderaxespad": 0.4,
|
|
112
|
+
"legend.labelspacing": 0.3,
|
|
113
|
+
# Data strokes & perceptual default colormap
|
|
114
|
+
"lines.linewidth": spec.data_linewidth_pt,
|
|
115
|
+
"lines.solid_capstyle": "round",
|
|
116
|
+
"lines.solid_joinstyle": "round",
|
|
117
|
+
"lines.markersize": 3.5,
|
|
118
|
+
"lines.markeredgewidth": 0.5,
|
|
119
|
+
"patch.linewidth": spec.axes_linewidth_pt,
|
|
120
|
+
"hatch.linewidth": spec.axes_linewidth_pt,
|
|
121
|
+
"errorbar.capsize": 1.5,
|
|
122
|
+
"image.cmap": "viridis",
|
|
123
|
+
# Figure & export defaults
|
|
124
|
+
"figure.facecolor": "white",
|
|
125
|
+
"figure.edgecolor": "white",
|
|
126
|
+
"figure.dpi": 150,
|
|
127
|
+
"savefig.facecolor": "white",
|
|
128
|
+
"savefig.edgecolor": "white",
|
|
129
|
+
"savefig.dpi": spec.dpi_combo,
|
|
130
|
+
"savefig.transparent": False,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def use(
|
|
135
|
+
journal: str | JournalSpec = "nature",
|
|
136
|
+
*,
|
|
137
|
+
palette: str | None = None,
|
|
138
|
+
) -> AbstractContextManager[None]:
|
|
139
|
+
"""Context manager applying journal rcParams without leaking global state."""
|
|
140
|
+
return mpl.rc_context(rc=rc_params(journal, palette=palette))
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def apply(
|
|
144
|
+
journal: str | JournalSpec = "nature",
|
|
145
|
+
*,
|
|
146
|
+
palette: str | None = None,
|
|
147
|
+
) -> dict[str, Any]:
|
|
148
|
+
"""Apply journal rcParams globally to ``matplotlib.rcParams`` and return them."""
|
|
149
|
+
params = rc_params(journal, palette=palette)
|
|
150
|
+
mpl.rcParams.update(params)
|
|
151
|
+
return params
|