plotastro 1.0.1__tar.gz → 1.1.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.
- {plotastro-1.0.1 → plotastro-1.1.0}/.gitignore +2 -0
- plotastro-1.1.0/CHANGELOG.md +133 -0
- plotastro-1.1.0/CITATION.cff +25 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/PKG-INFO +129 -18
- {plotastro-1.0.1 → plotastro-1.1.0}/README.md +125 -17
- plotastro-1.1.0/docs/api/accessibility.md +16 -0
- plotastro-1.1.0/docs/api/authors.md +48 -0
- plotastro-1.1.0/docs/api/cmasher.md +45 -0
- plotastro-1.1.0/docs/api/colors.md +136 -0
- plotastro-1.1.0/docs/api/markers.md +61 -0
- plotastro-1.1.0/docs/api/styles.md +122 -0
- plotastro-1.1.0/docs/api.md +102 -0
- plotastro-1.1.0/docs/colors.md +392 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/faq.md +9 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/index.md +10 -8
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/installation.md +31 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/journals.md +33 -2
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/quickstart.md +5 -0
- plotastro-1.1.0/examples/figures/cmasher.png +0 -0
- plotastro-1.1.0/examples/figures/cmasher_examples.png +0 -0
- plotastro-1.1.0/examples/figures/cmasher_maps.png +0 -0
- plotastro-1.1.0/examples/figures/example_column.png +0 -0
- plotastro-1.1.0/examples/figures/example_full.png +0 -0
- plotastro-1.1.0/examples/figures/redundant_encoding.png +0 -0
- plotastro-1.1.0/examples/make_reference_figures.py +211 -0
- plotastro-1.1.0/examples/tutorial.ipynb +1900 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/pyproject.toml +4 -2
- {plotastro-1.0.1 → plotastro-1.1.0}/requirements-dev.txt +1 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/__init__.py +9 -5
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/_authors.py +1 -1
- plotastro-1.1.0/src/plotastro/_colors.py +523 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/_core.py +95 -9
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/_extras.py +38 -3
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/aanda.mplstyle +8 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/apj.mplstyle +8 -1
- plotastro-1.1.0/src/plotastro/styles/euclid.mplstyle +126 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/jcap.mplstyle +8 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/mnras.mplstyle +8 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/natastro.mplstyle +8 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/oja.mplstyle +8 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/prd.mplstyle +8 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/src/plotastro/styles/rasti.mplstyle +8 -1
- {plotastro-1.0.1 → plotastro-1.1.0}/tests/test_authors.py +10 -0
- plotastro-1.1.0/tests/test_colors.py +180 -0
- plotastro-1.1.0/tests/test_docs.py +46 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/tests/test_sizing.py +2 -1
- plotastro-1.1.0/tests/test_styles.py +161 -0
- plotastro-1.1.0/tools/generate_styles.py +363 -0
- plotastro-1.0.1/CHANGELOG.md +0 -57
- plotastro-1.0.1/docs/api.md +0 -80
- plotastro-1.0.1/docs/colors.md +0 -76
- plotastro-1.0.1/examples/figures/example_column.png +0 -0
- plotastro-1.0.1/examples/figures/example_full.png +0 -0
- plotastro-1.0.1/examples/figures/redundant_encoding.png +0 -0
- plotastro-1.0.1/examples/make_reference_figures.py +0 -90
- plotastro-1.0.1/examples/tutorial.ipynb +0 -1281
- plotastro-1.0.1/src/plotastro/_colors.py +0 -227
- plotastro-1.0.1/tests/test_colors.py +0 -64
- plotastro-1.0.1/tests/test_styles.py +0 -69
- plotastro-1.0.1/tools/generate_styles.py +0 -202
- {plotastro-1.0.1 → plotastro-1.1.0}/.github/workflows/ci.yml +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/.github/workflows/publish.yml +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/.readthedocs.yaml +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/LICENSE +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/authors.md +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/changelog.md +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/conf.py +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/markers.md +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/docs/requirements.txt +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/examples/authors_example.csv +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/examples/figures/cvd_check.png +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/examples/figures/linestyles.png +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/examples/figures/markers.png +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/examples/figures/palette.png +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/examples/figures/palette_okabe_ito.png +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/requirements.txt +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/tests/conftest.py +0 -0
- {plotastro-1.0.1 → plotastro-1.1.0}/tests/test_extras.py +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.1.0 — 2026-10-06
|
|
4
|
+
|
|
5
|
+
The stable release of the 1.1 series: everything in the 1.1.0b1 and
|
|
6
|
+
1.1.0b2 betas below, plus documentation. `pip install plotastro` now
|
|
7
|
+
gives this version. No change in behaviour since 1.1.0b2.
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Install instructions for conda-forge
|
|
11
|
+
(`conda install -c conda-forge plotastro`, Python 3.11 or newer).
|
|
12
|
+
- The API reference is split into one page per topic (styles, colours,
|
|
13
|
+
CMasher, markers, authors, accessibility). The colours page has a
|
|
14
|
+
longer guide to colormaps: which map suits which kind of data, lines
|
|
15
|
+
coloured by a parameter with a colour bar, diverging and cyclic data,
|
|
16
|
+
and common errors. The tutorial notebook runs the same examples.
|
|
17
|
+
- The docstrings of `lighten`, `darken`, `check_colors`,
|
|
18
|
+
`current_journal`, `subplots`, `set_size`, `style_cycler`,
|
|
19
|
+
`show_colors`, `show_markers` and `show_linestyles` now list their
|
|
20
|
+
parameters and return values.
|
|
21
|
+
- A test checks that every public name is in the API reference and that
|
|
22
|
+
the constants it shows match the code.
|
|
23
|
+
|
|
24
|
+
## 1.1.0b2 — 2026-10-06 (beta)
|
|
25
|
+
|
|
26
|
+
A pre-release: `pip install plotastro` still gives the stable 1.0.1. To try
|
|
27
|
+
this beta, use `pip install --pre plotastro` (or `pip install
|
|
28
|
+
"plotastro==1.1.0b2"`).
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
- Legends now sit on a translucent white background (70 % opaque, no
|
|
32
|
+
border) instead of none, so they stay readable over data and grid
|
|
33
|
+
lines. The `euclid` style keeps niceplots' framed legends.
|
|
34
|
+
|
|
35
|
+
## 1.1.0b1 — 2026-10-06 (beta)
|
|
36
|
+
|
|
37
|
+
A pre-release: `pip install plotastro` still gives the stable 1.0.1. To try
|
|
38
|
+
this beta, use `pip install --pre plotastro` (or `pip install
|
|
39
|
+
"plotastro==1.1.0b1"`).
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
- `euclid` style (alias `ec`) for Euclid Consortium papers, adapted from
|
|
43
|
+
the Euclid Consortium Editorial Board's
|
|
44
|
+
[niceplots](https://gitlab.euclid-sgs.uk/ECEB/niceplots) (GPL-3.0,
|
|
45
|
+
Euclid-internal): sans-serif 10 pt text with Computer Modern maths, no
|
|
46
|
+
grid or minor ticks, framed legends, Petroff-8 colours, and niceplots'
|
|
47
|
+
4 × 3 in figure convention (LaTeX scales the figure into the A&A
|
|
48
|
+
column). The settings are re-expressed in plotastro's own template;
|
|
49
|
+
nothing is copied from niceplots.
|
|
50
|
+
- Palettes `PETROFF8` and `TOL_VIBRANT`, and `euclid_colors(scheme, n=)`
|
|
51
|
+
giving niceplots' five colour schemes under their niceplots names.
|
|
52
|
+
- `set_style(..., palette=...)` swaps the colour cycle for any named
|
|
53
|
+
palette or list of colours.
|
|
54
|
+
- Optional [CMasher](https://cmasher.readthedocs.io) support, for discrete
|
|
55
|
+
colours and colormaps: `cmasher_colors(cmap, n=8, cmap_range=(0.15, 0.85))`
|
|
56
|
+
samples colours from a CMasher map, `cmasher_cmap(cmap, cmap_range=, n=)`
|
|
57
|
+
returns the map (optionally cut, or split into `n` levels), and
|
|
58
|
+
`set_style` accepts `palette="cmr.<name>"`. CMasher is **not** a
|
|
59
|
+
dependency: install it with `pip install "plotastro[cmasher]"` (or
|
|
60
|
+
`pip install cmasher`). plotastro imports it only when one of these is
|
|
61
|
+
used, and without it they raise an `ImportError` saying how to install it.
|
|
62
|
+
- `set_style(..., cmap=...)` sets the default colormap: any matplotlib
|
|
63
|
+
name, or `"cmr.<name>"` for CMasher.
|
|
64
|
+
|
|
65
|
+
### Changed
|
|
66
|
+
- `figsize()` / `subplots()`: the default `aspect` now comes from the
|
|
67
|
+
journal (golden ratio everywhere except `euclid`, which uses 4:3).
|
|
68
|
+
- `authorlist(..., journal="euclid")` uses the A&A format (Euclid's
|
|
69
|
+
`aaEC` class).
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
- Switching styles in one session no longer carries settings over.
|
|
73
|
+
matplotlib only overwrites the rcParams a style names, and the styles
|
|
74
|
+
named different ones: after `euclid`, for example, `set_style("mnras")`
|
|
75
|
+
or `plt.style.use("mnras")` kept Euclid's tick padding. Every style now
|
|
76
|
+
sets the same rcParams, using matplotlib's defaults where they apply,
|
|
77
|
+
and a test checks this.
|
|
78
|
+
|
|
79
|
+
## 1.0.1 — 2026-09-01
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
- Documentation site (Sphinx + Furo on Read the Docs) with the rendered
|
|
83
|
+
tutorial notebook and a full API reference:
|
|
84
|
+
<https://plotastro.readthedocs.io>.
|
|
85
|
+
|
|
86
|
+
No changes to the package code itself.
|
|
87
|
+
|
|
88
|
+
## 1.0.0 — 2026-09-01
|
|
89
|
+
|
|
90
|
+
First release as an installable package, `plotastro`.
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
- `pip install plotastro`; importing it registers all styles with
|
|
94
|
+
matplotlib, so `plt.style.use("mnras")` works everywhere.
|
|
95
|
+
- Journal styles: **MNRAS**, **RASTI**, **A&A**, **ApJ/ApJL (AASTeX)**,
|
|
96
|
+
**Open Journal of Astrophysics**, **PRD/PRL (REVTeX)**, **JCAP**, and
|
|
97
|
+
**Nature Astronomy** (sans-serif variant), plus `thesis`/`beamer`
|
|
98
|
+
width presets. All generated from one template
|
|
99
|
+
(`tools/generate_styles.py`) so they stay consistent.
|
|
100
|
+
- Helpers: `set_style`, `figsize`, `subplots`, `savefig`,
|
|
101
|
+
`style_cycler`, `lighten`/`darken`, `label_panels` (journal-style
|
|
102
|
+
(a)/(b)/(c) panel labels), reference charts
|
|
103
|
+
(`show_colors`/`show_markers`/`show_linestyles`).
|
|
104
|
+
- Colour-vision-deficiency checking: `simulate_cvd`, `check_colors`,
|
|
105
|
+
and `check_figure` (Machado et al. 2009 model; no extra dependencies).
|
|
106
|
+
- Palettes: the default colour-blind-friendly cycle (`COLORS`), Okabe &
|
|
107
|
+
Ito (`OKABE_ITO`), Petroff-10 (`PETROFF10`) and light/dark pairs
|
|
108
|
+
(`PAIRED`).
|
|
109
|
+
- Author-list generator: `authorlist("authors.csv", journal=...)` and the
|
|
110
|
+
`plotastro-authors` command-line tool turn a CSV of names/affiliations/
|
|
111
|
+
ORCIDs/emails into the journal's LaTeX author block (MNRAS, A&A,
|
|
112
|
+
AASTeX, REVTeX, JCAP and generic formats), with automatic affiliation
|
|
113
|
+
numbering and sharing. Reads real collaboration lists as-is
|
|
114
|
+
(`Authorname`/`Firstname`+`Lastname` columns, one row per affiliation,
|
|
115
|
+
embedded LaTeX accents, extra columns ignored).
|
|
116
|
+
- Zero-learning-curve mode: importing plotastro registers every style
|
|
117
|
+
with matplotlib, so `plt.style.use("mnras")` + ordinary matplotlib is
|
|
118
|
+
the entire integration (`pa.use(...)` is an alias of `set_style`).
|
|
119
|
+
- `requirements.txt` / `requirements-dev.txt` for pip users; NumPy 1.x
|
|
120
|
+
and 2.x both supported and tested in CI.
|
|
121
|
+
- Tests (pytest), CI and PyPI-publishing GitHub Actions workflows,
|
|
122
|
+
executed tutorial notebook, MIT license.
|
|
123
|
+
|
|
124
|
+
### Changed
|
|
125
|
+
- Styles no longer require LaTeX: portable STIX mathtext by default,
|
|
126
|
+
with `set_style(..., usetex=True)` to opt in (newtx fonts).
|
|
127
|
+
- Submission-safe saving defaults: PDF, tight bbox, 450 dpi,
|
|
128
|
+
TrueType font embedding (`pdf.fonttype 42`).
|
|
129
|
+
|
|
130
|
+
### Migration from the original repo
|
|
131
|
+
- `MNRAS_Style.mplstyle` → `plt.style.use("mnras")` (after `import plotastro`).
|
|
132
|
+
- `myfigsize.set_size(...)` → `plotastro.set_size(...)` still works, but
|
|
133
|
+
prefer `plotastro.figsize(...)` / `plotastro.subplots(...)`.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# This CITATION.cff file was generated with cffinit.
|
|
2
|
+
# Visit https://bit.ly/cffinit to generate yours today!
|
|
3
|
+
|
|
4
|
+
cff-version: 1.2.0
|
|
5
|
+
title: plotastro
|
|
6
|
+
message: >-
|
|
7
|
+
If you use this software, please cite it using the
|
|
8
|
+
metadata from this file.
|
|
9
|
+
type: software
|
|
10
|
+
authors:
|
|
11
|
+
- given-names: Behnood
|
|
12
|
+
family-names: Bandi
|
|
13
|
+
email: b.bandi@sussex.ac.uk
|
|
14
|
+
affiliation: University of Sussex
|
|
15
|
+
orcid: 'https://orcid.org/0000-0001-5838-3903'
|
|
16
|
+
repository-code: 'https://github.com/BehnoodBandi/plotastro'
|
|
17
|
+
url: 'https://plotastro.readthedocs.io/'
|
|
18
|
+
keywords:
|
|
19
|
+
- Astronomy
|
|
20
|
+
- Python
|
|
21
|
+
- Plots
|
|
22
|
+
- Cosmology
|
|
23
|
+
- Journals
|
|
24
|
+
- matplotlib
|
|
25
|
+
license: MIT
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: plotastro
|
|
3
|
-
Version: 1.0
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Publication-quality matplotlib styles and helpers for astronomy journals (MNRAS, A&A, ApJ, OJA, PRD, JCAP, Nature Astronomy)
|
|
5
5
|
Project-URL: Homepage, https://github.com/BehnoodBandi/plotastro
|
|
6
6
|
Project-URL: Issues, https://github.com/BehnoodBandi/plotastro/issues
|
|
@@ -17,23 +17,34 @@ Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
|
17
17
|
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
18
18
|
Requires-Python: >=3.9
|
|
19
19
|
Requires-Dist: matplotlib>=3.5
|
|
20
|
+
Provides-Extra: cmasher
|
|
21
|
+
Requires-Dist: cmasher>=1.7; extra == 'cmasher'
|
|
20
22
|
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: cmasher>=1.7; extra == 'dev'
|
|
21
24
|
Requires-Dist: numpy; extra == 'dev'
|
|
22
25
|
Requires-Dist: pytest; extra == 'dev'
|
|
23
26
|
Description-Content-Type: text/markdown
|
|
24
27
|
|
|
25
28
|
# plotastro
|
|
26
29
|
|
|
30
|
+
[](https://pypi.org/project/plotastro/)
|
|
31
|
+
[](https://anaconda.org/conda-forge/plotastro)
|
|
32
|
+
[](https://pypi.org/project/plotastro/)
|
|
33
|
+
[](https://github.com/BehnoodBandi/plotastro/actions/workflows/ci.yml)
|
|
34
|
+
[](https://plotastro.readthedocs.io)
|
|
35
|
+
[](LICENSE)
|
|
36
|
+
|
|
27
37
|
**Publication-quality matplotlib figures for astronomy journals.**
|
|
28
38
|
|
|
29
39
|
One `pip install` gives you journal-matched styles for **MNRAS**, **RASTI**,
|
|
30
40
|
**A&A**, **ApJ/ApJL**, the **Open Journal of Astrophysics**, **PRD/PRL**,
|
|
31
|
-
**JCAP
|
|
32
|
-
size, a colour-blind-friendly palette, and
|
|
33
|
-
parts (sizing, panel labels, accessibility
|
|
41
|
+
**JCAP**, **Nature Astronomy** and **Euclid Consortium** papers — figures
|
|
42
|
+
at exactly the right physical size, a colour-blind-friendly palette, and
|
|
43
|
+
helpers that make the tedious parts (sizing, panel labels, accessibility
|
|
44
|
+
checks, saving) one-liners.
|
|
34
45
|
|
|
35
46
|
```bash
|
|
36
|
-
pip install plotastro
|
|
47
|
+
pip install plotastro # or: conda install -c conda-forge plotastro
|
|
37
48
|
```
|
|
38
49
|
|
|
39
50
|
**Simplest usage — no new API to learn.** Importing plotastro registers the
|
|
@@ -86,9 +97,11 @@ Two problems ruin most paper figures:
|
|
|
86
97
|
|
|
87
98
|
The styles share one visual language — Times-like serif fonts at ~9 pt with
|
|
88
99
|
~8 pt tick lettering, inward ticks on all four sides with minors, a subtle
|
|
89
|
-
grid,
|
|
100
|
+
grid, legends on a translucent white background — and differ only in figure width (plus the
|
|
90
101
|
sans-serif fonts Nature requires), so your plots stay **consistent between
|
|
91
|
-
papers** no matter where you submit.
|
|
102
|
+
papers** no matter where you submit. The one exception is `euclid`, which
|
|
103
|
+
deliberately matches the Euclid Consortium's own niceplots look instead
|
|
104
|
+
(see below).
|
|
92
105
|
|
|
93
106
|
## Supported journals
|
|
94
107
|
|
|
@@ -105,6 +118,7 @@ papers** no matter where you submit.
|
|
|
105
118
|
| `prd` (`prl`, `revtex`) | Physical Review D | 246.0 pt = 3.40 in | 510.0 pt = 7.06 in |
|
|
106
119
|
| `jcap` | J. Cosmology & Astroparticle Phys. | single-column ≈455 pt = 6.30 in | — |
|
|
107
120
|
| `natastro` (`nature`) | Nature Astronomy (sans-serif!) | 253.2 pt = 3.50 in (89 mm) | 520.7 pt = 7.20 in (183 mm) |
|
|
121
|
+
| `euclid` (`ec`) | Euclid Consortium papers (A&A; niceplots look, sans-serif) | drawn 4.00 in = 289.1 pt, LaTeX scales it to 88 mm | 8.00 in = 578.2 pt (2 × column) |
|
|
108
122
|
| `thesis` | A4 thesis text width | 426.8 pt = 5.91 in | — |
|
|
109
123
|
| `beamer` | Beamer slide text width | 307.3 pt = 4.25 in | — |
|
|
110
124
|
|
|
@@ -113,8 +127,37 @@ document, put `\the\columnwidth` or `\the\textwidth` in your `.tex` body,
|
|
|
113
127
|
compile, read the value off the page, and pass it directly:
|
|
114
128
|
`pa.figsize(width=345.0)`.
|
|
115
129
|
|
|
130
|
+
### Euclid Consortium papers
|
|
131
|
+
|
|
132
|
+
`pa.set_style("euclid")` reproduces the look of
|
|
133
|
+
[niceplots](https://gitlab.euclid-sgs.uk/ECEB/niceplots), the Euclid
|
|
134
|
+
Consortium Editorial Board's matplotlib style for Euclid papers
|
|
135
|
+
(Euclid-internal, GPL-3.0; set up by Lukas Hergt, with tweaks by Laila
|
|
136
|
+
Linke). The style and its colour schemes are **adapted from that
|
|
137
|
+
repository**: the settings are re-expressed in plotastro's own template and
|
|
138
|
+
nothing is copied from it. How it differs from the other styles:
|
|
139
|
+
|
|
140
|
+
- sans-serif text at 10 pt with Computer Modern maths, no grid, no minor
|
|
141
|
+
ticks, framed legends, and `axes.xmargin = 0`;
|
|
142
|
+
- the default cycle is Petroff's 8-colour palette (`pa.PETROFF8`);
|
|
143
|
+
niceplots' other schemes are available under their niceplots names —
|
|
144
|
+
`pa.set_style("euclid", palette="categorical3")` or
|
|
145
|
+
`pa.euclid_colors("sequential", n=6)` (see *The colour palette* below);
|
|
146
|
+
- **sizing follows niceplots rather than the exact-size approach**: figures
|
|
147
|
+
are drawn 4 × 3 in (two-column: 8 × 6 in) and LaTeX scales them into the
|
|
148
|
+
88 mm A&A column, so the 10 pt lettering prints at ≈ 8.7 pt. Include them
|
|
149
|
+
with `\includegraphics[width=\columnwidth]{fig.pdf}`. For a figure at
|
|
150
|
+
its exact printed size with the Euclid look, size it for A&A instead:
|
|
151
|
+
`pa.subplots(journal="aanda")`.
|
|
152
|
+
|
|
153
|
+
`pa.set_style("euclid", usetex=True)` gives niceplots' LaTeX rendering
|
|
154
|
+
(Computer Modern Sans text). Euclid papers use A&A's `aaEC` class, so
|
|
155
|
+
`pa.authorlist(..., journal="euclid")` produces the A&A author block.
|
|
156
|
+
|
|
116
157
|
The only hard dependency is matplotlib; plotastro works with both NumPy 1.x
|
|
117
|
-
and 2.x (CI tests each).
|
|
158
|
+
and 2.x (CI tests each). [CMasher](https://cmasher.readthedocs.io) colours
|
|
159
|
+
and colormaps are an optional extra (`pip install "plotastro[cmasher]"`; see
|
|
160
|
+
below). Running the examples from a clone?
|
|
118
161
|
`pip install -r requirements-dev.txt`.
|
|
119
162
|
|
|
120
163
|
## Tutorial
|
|
@@ -166,20 +209,77 @@ ax.fill_between(x, lo, hi, color=pa.lighten(pa.COLORS["blue"], 0.7))
|
|
|
166
209
|
pa.darken(pa.COLORS["orange"], 0.3) # the other direction
|
|
167
210
|
```
|
|
168
211
|
|
|
169
|
-
|
|
212
|
+
More palettes ship with the package:
|
|
170
213
|
|
|
171
214
|
- `pa.OKABE_ITO` — [Okabe & Ito (2008)](https://jfly.uni-koeln.de/color/),
|
|
172
215
|
*the* classic CVD-safe recommendation for categorical colours in science;
|
|
173
216
|
- `pa.PETROFF10` — [Petroff (2021)](https://arxiv.org/abs/2107.02270), the
|
|
174
217
|
CVD-optimised 10-colour cycle used across particle physics;
|
|
218
|
+
- `pa.PETROFF8` — Petroff's 8-colour sibling, the default cycle of the
|
|
219
|
+
Euclid Consortium's [niceplots](https://gitlab.euclid-sgs.uk/ECEB/niceplots)
|
|
220
|
+
(and of the `euclid` style here);
|
|
221
|
+
- `pa.TOL_VIBRANT` — [Paul Tol's](https://personal.sron.nl/~pault/) *vibrant*
|
|
222
|
+
qualitative scheme, 7 CVD-safe colours;
|
|
175
223
|
- `pa.PAIRED` — light/dark pairs for data/model or before/after comparisons:
|
|
176
224
|
`pa.PAIRED["blue"]` → `("#a6cee3", "#1f78b4")`.
|
|
177
225
|
|
|
226
|
+
Any of them can become the active cycle when you activate a style —
|
|
227
|
+
`pa.set_style("mnras", palette="okabe_ito")` — or pass your own list of
|
|
228
|
+
colours. The colour schemes of the Euclid Consortium's niceplots are also
|
|
229
|
+
available under their niceplots names (adapted from that repository):
|
|
230
|
+
`pa.euclid_colors()` takes `"categorical1"` (Petroff-8), `"categorical2"`
|
|
231
|
+
(Okabe & Ito), `"categorical3"` (black + Tol vibrant), `"sequential"` (`n`
|
|
232
|
+
colours from `copper`) or `"diverging"` (`n` colours from `coolwarm`):
|
|
233
|
+
|
|
234
|
+
```python
|
|
235
|
+
pa.set_style("euclid", palette="diverging") # by name
|
|
236
|
+
ax.set_prop_cycle(color=pa.euclid_colors("sequential", n=6)) # per axes
|
|
237
|
+
```
|
|
238
|
+
|
|
178
239
|
**Colormaps:** the styles default to `viridis` (perceptually uniform,
|
|
179
240
|
CVD-safe). Good picks: `viridis`/`magma`/`cividis` for sequential data,
|
|
180
241
|
`RdBu_r` or `coolwarm` for diverging data (red–*blue*, not red–green). Avoid
|
|
181
|
-
`jet`/`rainbow`.
|
|
182
|
-
|
|
242
|
+
`jet`/`rainbow`. Change the default with `pa.set_style("mnras", cmap="cividis")`.
|
|
243
|
+
For many more maps, use CMasher (next section) or
|
|
244
|
+
[cmocean](https://matplotlib.org/cmocean/).
|
|
245
|
+
|
|
246
|
+
### CMasher colours and colormaps (optional)
|
|
247
|
+
|
|
248
|
+

|
|
249
|
+
|
|
250
|
+
[CMasher](https://cmasher.readthedocs.io) (van der Velden 2020,
|
|
251
|
+
[JOSS 5, 2004](https://doi.org/10.21105/joss.02004)) is a collection of
|
|
252
|
+
perceptually uniform scientific colormaps (sequential, diverging and
|
|
253
|
+
cyclic), most of them colour-vision-deficiency friendly. plotastro can use
|
|
254
|
+
it for both discrete colours and colormaps, but it is **not a dependency**.
|
|
255
|
+
Install it only if you want it (`pip install cmasher`, or
|
|
256
|
+
`pip install "plotastro[cmasher]"`); plotastro imports it only when you ask
|
|
257
|
+
for a CMasher colour. Names start with `cmr.`, as in CMasher itself:
|
|
258
|
+
|
|
259
|
+
```python
|
|
260
|
+
pa.set_style("mnras", palette="cmr.rainforest") # 8-colour cycle from a CMasher map
|
|
261
|
+
pa.set_style("mnras", cmap="cmr.ocean") # default colormap for imshow etc.
|
|
262
|
+
|
|
263
|
+
ax.set_prop_cycle(color=pa.cmasher_colors("torch", n=5)) # n discrete colours
|
|
264
|
+
ax.imshow(img, cmap=pa.cmasher_cmap("rainforest")) # the colormap
|
|
265
|
+
ax.contourf(x, y, z, levels=6, cmap=pa.cmasher_cmap("iceburn", n=6)) # 6 levels
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Discrete colours are sampled from `cmap_range=(0.15, 0.85)` by default.
|
|
269
|
+
This follows CMasher's advice, since most of its sequential maps run from
|
|
270
|
+
black to white and those ends vanish on the page. For lines that must be
|
|
271
|
+
easy to tell apart, CMasher suggests `apple`, `chroma`, `neon`,
|
|
272
|
+
`rainforest` or `torch`; for steps of one quantity, a single-hue map such
|
|
273
|
+
as `flamingo`, `freeze`, `gothic`, `jungle` or `ocean`. To span the whole
|
|
274
|
+
map with a fixed number of lines, sample exactly that many:
|
|
275
|
+
`pa.cmasher_colors("rainforest", n=len(models))`. Please cite CMasher if
|
|
276
|
+
you use it (`cmasher.get_bibtex()`).
|
|
277
|
+
|
|
278
|
+
The [colours page of the documentation](https://plotastro.readthedocs.io/en/latest/colors.html)
|
|
279
|
+
has more: which map suits which kind of data, lines coloured by a
|
|
280
|
+
parameter with a colour bar, diverging and cyclic data, and common
|
|
281
|
+
errors. The [tutorial notebook](examples/tutorial.ipynb) runs the same
|
|
282
|
+
examples.
|
|
183
283
|
|
|
184
284
|
### Checking accessibility yourself
|
|
185
285
|
|
|
@@ -271,9 +371,10 @@ your manuscript (custom macros, real kerning):
|
|
|
271
371
|
pa.set_style("mnras", usetex=True) # needs latex + dvipng + ghostscript
|
|
272
372
|
```
|
|
273
373
|
|
|
274
|
-
This loads the `newtx` Times fonts (matching the MNRAS/A&A house font),
|
|
275
|
-
Helvetica for Nature Astronomy
|
|
276
|
-
|
|
374
|
+
This loads the `newtx` Times fonts (matching the MNRAS/A&A house font),
|
|
375
|
+
Helvetica for Nature Astronomy, or plain Computer Modern Sans for the Euclid
|
|
376
|
+
style (as niceplots does). Develop with `usetex=False`, flip it on for the
|
|
377
|
+
final version — LaTeX rendering is slow.
|
|
277
378
|
|
|
278
379
|
### Saving figures
|
|
279
380
|
|
|
@@ -355,14 +456,16 @@ complete example.
|
|
|
355
456
|
|
|
356
457
|
| | |
|
|
357
458
|
|---|---|
|
|
358
|
-
| `set_style(journal, usetex=, grid=, **rc)` | activate a journal's style (alias: `use`) |
|
|
459
|
+
| `set_style(journal, usetex=, grid=, palette=, cmap=, **rc)` | activate a journal's style (alias: `use`) |
|
|
359
460
|
| `authorlist(csv, journal=)` | LaTeX author/affiliation block from a CSV (CLI: `plotastro-authors`) |
|
|
360
461
|
| `figsize(width, journal=, fraction=, aspect=, ...)` | journal-correct figure dimensions |
|
|
361
462
|
| `subplots(...)` | `plt.subplots` with the size computed for you |
|
|
362
463
|
| `savefig(name, formats=("pdf",))` | save one figure in several formats |
|
|
363
464
|
| `label_panels(axes, ...)` | (a), (b), (c) panel labels |
|
|
364
465
|
| `style_cycler(markers=, linestyles=)` | redundant-encoding property cycle |
|
|
365
|
-
| `COLORS`, `CYCLE`, `OKABE_ITO`, `PETROFF10`, `PAIRED` | palettes |
|
|
466
|
+
| `COLORS`, `CYCLE`, `OKABE_ITO`, `PETROFF8`, `PETROFF10`, `TOL_VIBRANT`, `PAIRED` | palettes |
|
|
467
|
+
| `euclid_colors(scheme, n=)` | the Euclid niceplots colour schemes, by name |
|
|
468
|
+
| `cmasher_colors(cmap, n=, cmap_range=)`, `cmasher_cmap(cmap, cmap_range=, n=)` | CMasher colours / colormaps (optional `cmasher` package) |
|
|
366
469
|
| `lighten(c, f)`, `darken(c, f)` | matched shades without transparency |
|
|
367
470
|
| `simulate_cvd`, `check_colors`, `check_figure` | colour-vision-deficiency checks |
|
|
368
471
|
| `MARKERS`, `LINESTYLES` | curated marker / dash-pattern sequences |
|
|
@@ -403,7 +506,7 @@ python tools/generate_styles.py # regenerate styles/ after editing the templ
|
|
|
403
506
|
python examples/make_reference_figures.py # regenerate README figures
|
|
404
507
|
```
|
|
405
508
|
|
|
406
|
-
The `.mplstyle` files are generated from
|
|
509
|
+
The `.mplstyle` files are generated from the templates in
|
|
407
510
|
[tools/generate_styles.py](tools/generate_styles.py) — edit that, not the
|
|
408
511
|
files (CI checks they stay in sync). Releases: bump the version in
|
|
409
512
|
`pyproject.toml` and `CHANGELOG.md`, then push a `v*` tag — the
|
|
@@ -418,7 +521,15 @@ files (CI checks they stay in sync). Releases: bump the version in
|
|
|
418
521
|
[Thøger Rivera-Thorsen](https://gist.github.com/thriveth/8560036);
|
|
419
522
|
light colours from Tableau *Color Blind 10*
|
|
420
523
|
- Palettes: [Okabe & Ito](https://jfly.uni-koeln.de/color/),
|
|
421
|
-
[Petroff (2021)](https://arxiv.org/abs/2107.02270),
|
|
524
|
+
[Petroff (2021)](https://arxiv.org/abs/2107.02270),
|
|
525
|
+
[Paul Tol](https://personal.sron.nl/~pault/), ColorBrewer *Paired*
|
|
526
|
+
- Optional colormaps: [CMasher](https://cmasher.readthedocs.io)
|
|
527
|
+
(E. van der Velden 2020, JOSS 5, 2004; BSD-3-Clause), used as an optional
|
|
528
|
+
dependency, not bundled
|
|
529
|
+
- Euclid style and colour schemes adapted from the Euclid Consortium
|
|
530
|
+
Editorial Board's [niceplots](https://gitlab.euclid-sgs.uk/ECEB/niceplots)
|
|
531
|
+
(Lukas Hergt and Laila Linke; GPL-3.0, Euclid-internal) — settings
|
|
532
|
+
re-expressed in plotastro's own template, nothing copied
|
|
422
533
|
- CVD model: Machado, Oliveira & Fernandes (2009), IEEE TVCG 15(6)
|
|
423
534
|
- Figure-size approach after
|
|
424
535
|
[Jack Walton's guide](https://jwalton.info/Embed-Publication-Matplotlib-Latex/)
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
# plotastro
|
|
2
2
|
|
|
3
|
+
[](https://pypi.org/project/plotastro/)
|
|
4
|
+
[](https://anaconda.org/conda-forge/plotastro)
|
|
5
|
+
[](https://pypi.org/project/plotastro/)
|
|
6
|
+
[](https://github.com/BehnoodBandi/plotastro/actions/workflows/ci.yml)
|
|
7
|
+
[](https://plotastro.readthedocs.io)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
3
10
|
**Publication-quality matplotlib figures for astronomy journals.**
|
|
4
11
|
|
|
5
12
|
One `pip install` gives you journal-matched styles for **MNRAS**, **RASTI**,
|
|
6
13
|
**A&A**, **ApJ/ApJL**, the **Open Journal of Astrophysics**, **PRD/PRL**,
|
|
7
|
-
**JCAP
|
|
8
|
-
size, a colour-blind-friendly palette, and
|
|
9
|
-
parts (sizing, panel labels, accessibility
|
|
14
|
+
**JCAP**, **Nature Astronomy** and **Euclid Consortium** papers — figures
|
|
15
|
+
at exactly the right physical size, a colour-blind-friendly palette, and
|
|
16
|
+
helpers that make the tedious parts (sizing, panel labels, accessibility
|
|
17
|
+
checks, saving) one-liners.
|
|
10
18
|
|
|
11
19
|
```bash
|
|
12
|
-
pip install plotastro
|
|
20
|
+
pip install plotastro # or: conda install -c conda-forge plotastro
|
|
13
21
|
```
|
|
14
22
|
|
|
15
23
|
**Simplest usage — no new API to learn.** Importing plotastro registers the
|
|
@@ -62,9 +70,11 @@ Two problems ruin most paper figures:
|
|
|
62
70
|
|
|
63
71
|
The styles share one visual language — Times-like serif fonts at ~9 pt with
|
|
64
72
|
~8 pt tick lettering, inward ticks on all four sides with minors, a subtle
|
|
65
|
-
grid,
|
|
73
|
+
grid, legends on a translucent white background — and differ only in figure width (plus the
|
|
66
74
|
sans-serif fonts Nature requires), so your plots stay **consistent between
|
|
67
|
-
papers** no matter where you submit.
|
|
75
|
+
papers** no matter where you submit. The one exception is `euclid`, which
|
|
76
|
+
deliberately matches the Euclid Consortium's own niceplots look instead
|
|
77
|
+
(see below).
|
|
68
78
|
|
|
69
79
|
## Supported journals
|
|
70
80
|
|
|
@@ -81,6 +91,7 @@ papers** no matter where you submit.
|
|
|
81
91
|
| `prd` (`prl`, `revtex`) | Physical Review D | 246.0 pt = 3.40 in | 510.0 pt = 7.06 in |
|
|
82
92
|
| `jcap` | J. Cosmology & Astroparticle Phys. | single-column ≈455 pt = 6.30 in | — |
|
|
83
93
|
| `natastro` (`nature`) | Nature Astronomy (sans-serif!) | 253.2 pt = 3.50 in (89 mm) | 520.7 pt = 7.20 in (183 mm) |
|
|
94
|
+
| `euclid` (`ec`) | Euclid Consortium papers (A&A; niceplots look, sans-serif) | drawn 4.00 in = 289.1 pt, LaTeX scales it to 88 mm | 8.00 in = 578.2 pt (2 × column) |
|
|
84
95
|
| `thesis` | A4 thesis text width | 426.8 pt = 5.91 in | — |
|
|
85
96
|
| `beamer` | Beamer slide text width | 307.3 pt = 4.25 in | — |
|
|
86
97
|
|
|
@@ -89,8 +100,37 @@ document, put `\the\columnwidth` or `\the\textwidth` in your `.tex` body,
|
|
|
89
100
|
compile, read the value off the page, and pass it directly:
|
|
90
101
|
`pa.figsize(width=345.0)`.
|
|
91
102
|
|
|
103
|
+
### Euclid Consortium papers
|
|
104
|
+
|
|
105
|
+
`pa.set_style("euclid")` reproduces the look of
|
|
106
|
+
[niceplots](https://gitlab.euclid-sgs.uk/ECEB/niceplots), the Euclid
|
|
107
|
+
Consortium Editorial Board's matplotlib style for Euclid papers
|
|
108
|
+
(Euclid-internal, GPL-3.0; set up by Lukas Hergt, with tweaks by Laila
|
|
109
|
+
Linke). The style and its colour schemes are **adapted from that
|
|
110
|
+
repository**: the settings are re-expressed in plotastro's own template and
|
|
111
|
+
nothing is copied from it. How it differs from the other styles:
|
|
112
|
+
|
|
113
|
+
- sans-serif text at 10 pt with Computer Modern maths, no grid, no minor
|
|
114
|
+
ticks, framed legends, and `axes.xmargin = 0`;
|
|
115
|
+
- the default cycle is Petroff's 8-colour palette (`pa.PETROFF8`);
|
|
116
|
+
niceplots' other schemes are available under their niceplots names —
|
|
117
|
+
`pa.set_style("euclid", palette="categorical3")` or
|
|
118
|
+
`pa.euclid_colors("sequential", n=6)` (see *The colour palette* below);
|
|
119
|
+
- **sizing follows niceplots rather than the exact-size approach**: figures
|
|
120
|
+
are drawn 4 × 3 in (two-column: 8 × 6 in) and LaTeX scales them into the
|
|
121
|
+
88 mm A&A column, so the 10 pt lettering prints at ≈ 8.7 pt. Include them
|
|
122
|
+
with `\includegraphics[width=\columnwidth]{fig.pdf}`. For a figure at
|
|
123
|
+
its exact printed size with the Euclid look, size it for A&A instead:
|
|
124
|
+
`pa.subplots(journal="aanda")`.
|
|
125
|
+
|
|
126
|
+
`pa.set_style("euclid", usetex=True)` gives niceplots' LaTeX rendering
|
|
127
|
+
(Computer Modern Sans text). Euclid papers use A&A's `aaEC` class, so
|
|
128
|
+
`pa.authorlist(..., journal="euclid")` produces the A&A author block.
|
|
129
|
+
|
|
92
130
|
The only hard dependency is matplotlib; plotastro works with both NumPy 1.x
|
|
93
|
-
and 2.x (CI tests each).
|
|
131
|
+
and 2.x (CI tests each). [CMasher](https://cmasher.readthedocs.io) colours
|
|
132
|
+
and colormaps are an optional extra (`pip install "plotastro[cmasher]"`; see
|
|
133
|
+
below). Running the examples from a clone?
|
|
94
134
|
`pip install -r requirements-dev.txt`.
|
|
95
135
|
|
|
96
136
|
## Tutorial
|
|
@@ -142,20 +182,77 @@ ax.fill_between(x, lo, hi, color=pa.lighten(pa.COLORS["blue"], 0.7))
|
|
|
142
182
|
pa.darken(pa.COLORS["orange"], 0.3) # the other direction
|
|
143
183
|
```
|
|
144
184
|
|
|
145
|
-
|
|
185
|
+
More palettes ship with the package:
|
|
146
186
|
|
|
147
187
|
- `pa.OKABE_ITO` — [Okabe & Ito (2008)](https://jfly.uni-koeln.de/color/),
|
|
148
188
|
*the* classic CVD-safe recommendation for categorical colours in science;
|
|
149
189
|
- `pa.PETROFF10` — [Petroff (2021)](https://arxiv.org/abs/2107.02270), the
|
|
150
190
|
CVD-optimised 10-colour cycle used across particle physics;
|
|
191
|
+
- `pa.PETROFF8` — Petroff's 8-colour sibling, the default cycle of the
|
|
192
|
+
Euclid Consortium's [niceplots](https://gitlab.euclid-sgs.uk/ECEB/niceplots)
|
|
193
|
+
(and of the `euclid` style here);
|
|
194
|
+
- `pa.TOL_VIBRANT` — [Paul Tol's](https://personal.sron.nl/~pault/) *vibrant*
|
|
195
|
+
qualitative scheme, 7 CVD-safe colours;
|
|
151
196
|
- `pa.PAIRED` — light/dark pairs for data/model or before/after comparisons:
|
|
152
197
|
`pa.PAIRED["blue"]` → `("#a6cee3", "#1f78b4")`.
|
|
153
198
|
|
|
199
|
+
Any of them can become the active cycle when you activate a style —
|
|
200
|
+
`pa.set_style("mnras", palette="okabe_ito")` — or pass your own list of
|
|
201
|
+
colours. The colour schemes of the Euclid Consortium's niceplots are also
|
|
202
|
+
available under their niceplots names (adapted from that repository):
|
|
203
|
+
`pa.euclid_colors()` takes `"categorical1"` (Petroff-8), `"categorical2"`
|
|
204
|
+
(Okabe & Ito), `"categorical3"` (black + Tol vibrant), `"sequential"` (`n`
|
|
205
|
+
colours from `copper`) or `"diverging"` (`n` colours from `coolwarm`):
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
pa.set_style("euclid", palette="diverging") # by name
|
|
209
|
+
ax.set_prop_cycle(color=pa.euclid_colors("sequential", n=6)) # per axes
|
|
210
|
+
```
|
|
211
|
+
|
|
154
212
|
**Colormaps:** the styles default to `viridis` (perceptually uniform,
|
|
155
213
|
CVD-safe). Good picks: `viridis`/`magma`/`cividis` for sequential data,
|
|
156
214
|
`RdBu_r` or `coolwarm` for diverging data (red–*blue*, not red–green). Avoid
|
|
157
|
-
`jet`/`rainbow`.
|
|
158
|
-
|
|
215
|
+
`jet`/`rainbow`. Change the default with `pa.set_style("mnras", cmap="cividis")`.
|
|
216
|
+
For many more maps, use CMasher (next section) or
|
|
217
|
+
[cmocean](https://matplotlib.org/cmocean/).
|
|
218
|
+
|
|
219
|
+
### CMasher colours and colormaps (optional)
|
|
220
|
+
|
|
221
|
+

|
|
222
|
+
|
|
223
|
+
[CMasher](https://cmasher.readthedocs.io) (van der Velden 2020,
|
|
224
|
+
[JOSS 5, 2004](https://doi.org/10.21105/joss.02004)) is a collection of
|
|
225
|
+
perceptually uniform scientific colormaps (sequential, diverging and
|
|
226
|
+
cyclic), most of them colour-vision-deficiency friendly. plotastro can use
|
|
227
|
+
it for both discrete colours and colormaps, but it is **not a dependency**.
|
|
228
|
+
Install it only if you want it (`pip install cmasher`, or
|
|
229
|
+
`pip install "plotastro[cmasher]"`); plotastro imports it only when you ask
|
|
230
|
+
for a CMasher colour. Names start with `cmr.`, as in CMasher itself:
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
pa.set_style("mnras", palette="cmr.rainforest") # 8-colour cycle from a CMasher map
|
|
234
|
+
pa.set_style("mnras", cmap="cmr.ocean") # default colormap for imshow etc.
|
|
235
|
+
|
|
236
|
+
ax.set_prop_cycle(color=pa.cmasher_colors("torch", n=5)) # n discrete colours
|
|
237
|
+
ax.imshow(img, cmap=pa.cmasher_cmap("rainforest")) # the colormap
|
|
238
|
+
ax.contourf(x, y, z, levels=6, cmap=pa.cmasher_cmap("iceburn", n=6)) # 6 levels
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Discrete colours are sampled from `cmap_range=(0.15, 0.85)` by default.
|
|
242
|
+
This follows CMasher's advice, since most of its sequential maps run from
|
|
243
|
+
black to white and those ends vanish on the page. For lines that must be
|
|
244
|
+
easy to tell apart, CMasher suggests `apple`, `chroma`, `neon`,
|
|
245
|
+
`rainforest` or `torch`; for steps of one quantity, a single-hue map such
|
|
246
|
+
as `flamingo`, `freeze`, `gothic`, `jungle` or `ocean`. To span the whole
|
|
247
|
+
map with a fixed number of lines, sample exactly that many:
|
|
248
|
+
`pa.cmasher_colors("rainforest", n=len(models))`. Please cite CMasher if
|
|
249
|
+
you use it (`cmasher.get_bibtex()`).
|
|
250
|
+
|
|
251
|
+
The [colours page of the documentation](https://plotastro.readthedocs.io/en/latest/colors.html)
|
|
252
|
+
has more: which map suits which kind of data, lines coloured by a
|
|
253
|
+
parameter with a colour bar, diverging and cyclic data, and common
|
|
254
|
+
errors. The [tutorial notebook](examples/tutorial.ipynb) runs the same
|
|
255
|
+
examples.
|
|
159
256
|
|
|
160
257
|
### Checking accessibility yourself
|
|
161
258
|
|
|
@@ -247,9 +344,10 @@ your manuscript (custom macros, real kerning):
|
|
|
247
344
|
pa.set_style("mnras", usetex=True) # needs latex + dvipng + ghostscript
|
|
248
345
|
```
|
|
249
346
|
|
|
250
|
-
This loads the `newtx` Times fonts (matching the MNRAS/A&A house font),
|
|
251
|
-
Helvetica for Nature Astronomy
|
|
252
|
-
|
|
347
|
+
This loads the `newtx` Times fonts (matching the MNRAS/A&A house font),
|
|
348
|
+
Helvetica for Nature Astronomy, or plain Computer Modern Sans for the Euclid
|
|
349
|
+
style (as niceplots does). Develop with `usetex=False`, flip it on for the
|
|
350
|
+
final version — LaTeX rendering is slow.
|
|
253
351
|
|
|
254
352
|
### Saving figures
|
|
255
353
|
|
|
@@ -331,14 +429,16 @@ complete example.
|
|
|
331
429
|
|
|
332
430
|
| | |
|
|
333
431
|
|---|---|
|
|
334
|
-
| `set_style(journal, usetex=, grid=, **rc)` | activate a journal's style (alias: `use`) |
|
|
432
|
+
| `set_style(journal, usetex=, grid=, palette=, cmap=, **rc)` | activate a journal's style (alias: `use`) |
|
|
335
433
|
| `authorlist(csv, journal=)` | LaTeX author/affiliation block from a CSV (CLI: `plotastro-authors`) |
|
|
336
434
|
| `figsize(width, journal=, fraction=, aspect=, ...)` | journal-correct figure dimensions |
|
|
337
435
|
| `subplots(...)` | `plt.subplots` with the size computed for you |
|
|
338
436
|
| `savefig(name, formats=("pdf",))` | save one figure in several formats |
|
|
339
437
|
| `label_panels(axes, ...)` | (a), (b), (c) panel labels |
|
|
340
438
|
| `style_cycler(markers=, linestyles=)` | redundant-encoding property cycle |
|
|
341
|
-
| `COLORS`, `CYCLE`, `OKABE_ITO`, `PETROFF10`, `PAIRED` | palettes |
|
|
439
|
+
| `COLORS`, `CYCLE`, `OKABE_ITO`, `PETROFF8`, `PETROFF10`, `TOL_VIBRANT`, `PAIRED` | palettes |
|
|
440
|
+
| `euclid_colors(scheme, n=)` | the Euclid niceplots colour schemes, by name |
|
|
441
|
+
| `cmasher_colors(cmap, n=, cmap_range=)`, `cmasher_cmap(cmap, cmap_range=, n=)` | CMasher colours / colormaps (optional `cmasher` package) |
|
|
342
442
|
| `lighten(c, f)`, `darken(c, f)` | matched shades without transparency |
|
|
343
443
|
| `simulate_cvd`, `check_colors`, `check_figure` | colour-vision-deficiency checks |
|
|
344
444
|
| `MARKERS`, `LINESTYLES` | curated marker / dash-pattern sequences |
|
|
@@ -379,7 +479,7 @@ python tools/generate_styles.py # regenerate styles/ after editing the templ
|
|
|
379
479
|
python examples/make_reference_figures.py # regenerate README figures
|
|
380
480
|
```
|
|
381
481
|
|
|
382
|
-
The `.mplstyle` files are generated from
|
|
482
|
+
The `.mplstyle` files are generated from the templates in
|
|
383
483
|
[tools/generate_styles.py](tools/generate_styles.py) — edit that, not the
|
|
384
484
|
files (CI checks they stay in sync). Releases: bump the version in
|
|
385
485
|
`pyproject.toml` and `CHANGELOG.md`, then push a `v*` tag — the
|
|
@@ -394,7 +494,15 @@ files (CI checks they stay in sync). Releases: bump the version in
|
|
|
394
494
|
[Thøger Rivera-Thorsen](https://gist.github.com/thriveth/8560036);
|
|
395
495
|
light colours from Tableau *Color Blind 10*
|
|
396
496
|
- Palettes: [Okabe & Ito](https://jfly.uni-koeln.de/color/),
|
|
397
|
-
[Petroff (2021)](https://arxiv.org/abs/2107.02270),
|
|
497
|
+
[Petroff (2021)](https://arxiv.org/abs/2107.02270),
|
|
498
|
+
[Paul Tol](https://personal.sron.nl/~pault/), ColorBrewer *Paired*
|
|
499
|
+
- Optional colormaps: [CMasher](https://cmasher.readthedocs.io)
|
|
500
|
+
(E. van der Velden 2020, JOSS 5, 2004; BSD-3-Clause), used as an optional
|
|
501
|
+
dependency, not bundled
|
|
502
|
+
- Euclid style and colour schemes adapted from the Euclid Consortium
|
|
503
|
+
Editorial Board's [niceplots](https://gitlab.euclid-sgs.uk/ECEB/niceplots)
|
|
504
|
+
(Lukas Hergt and Laila Linke; GPL-3.0, Euclid-internal) — settings
|
|
505
|
+
re-expressed in plotastro's own template, nothing copied
|
|
398
506
|
- CVD model: Machado, Oliveira & Fernandes (2009), IEEE TVCG 15(6)
|
|
399
507
|
- Figure-size approach after
|
|
400
508
|
[Jack Walton's guide](https://jwalton.info/Embed-Publication-Matplotlib-Latex/)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Colour-vision-deficiency checks
|
|
2
|
+
|
|
3
|
+
Simulate how colours, palettes and whole figures look to readers with a
|
|
4
|
+
colour-vision deficiency, and in greyscale print. The simulations use the
|
|
5
|
+
Machado, Oliveira & Fernandes (2009) model and need no extra packages. See
|
|
6
|
+
{doc}`../colors` for the guide.
|
|
7
|
+
|
|
8
|
+
```{eval-rst}
|
|
9
|
+
.. currentmodule:: plotastro
|
|
10
|
+
|
|
11
|
+
.. autofunction:: simulate_cvd
|
|
12
|
+
|
|
13
|
+
.. autofunction:: check_colors
|
|
14
|
+
|
|
15
|
+
.. autofunction:: check_figure
|
|
16
|
+
```
|