plotastro 1.0.0__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.
Files changed (76) hide show
  1. {plotastro-1.0.0 → plotastro-1.1.0}/.gitignore +5 -0
  2. plotastro-1.1.0/.readthedocs.yaml +17 -0
  3. plotastro-1.1.0/CHANGELOG.md +133 -0
  4. plotastro-1.1.0/CITATION.cff +25 -0
  5. {plotastro-1.0.0 → plotastro-1.1.0}/PKG-INFO +132 -20
  6. {plotastro-1.0.0 → plotastro-1.1.0}/README.md +128 -19
  7. plotastro-1.1.0/docs/api/accessibility.md +16 -0
  8. plotastro-1.1.0/docs/api/authors.md +48 -0
  9. plotastro-1.1.0/docs/api/cmasher.md +45 -0
  10. plotastro-1.1.0/docs/api/colors.md +136 -0
  11. plotastro-1.1.0/docs/api/markers.md +61 -0
  12. plotastro-1.1.0/docs/api/styles.md +122 -0
  13. plotastro-1.1.0/docs/api.md +102 -0
  14. plotastro-1.1.0/docs/authors.md +78 -0
  15. plotastro-1.1.0/docs/changelog.md +2 -0
  16. plotastro-1.1.0/docs/colors.md +392 -0
  17. plotastro-1.1.0/docs/conf.py +72 -0
  18. plotastro-1.1.0/docs/faq.md +55 -0
  19. plotastro-1.1.0/docs/index.md +93 -0
  20. plotastro-1.1.0/docs/installation.md +71 -0
  21. plotastro-1.1.0/docs/journals.md +82 -0
  22. plotastro-1.1.0/docs/markers.md +73 -0
  23. plotastro-1.1.0/docs/quickstart.md +104 -0
  24. plotastro-1.1.0/docs/requirements.txt +5 -0
  25. plotastro-1.1.0/examples/figures/cmasher.png +0 -0
  26. plotastro-1.1.0/examples/figures/cmasher_examples.png +0 -0
  27. plotastro-1.1.0/examples/figures/cmasher_maps.png +0 -0
  28. plotastro-1.1.0/examples/figures/example_column.png +0 -0
  29. plotastro-1.1.0/examples/figures/example_full.png +0 -0
  30. plotastro-1.1.0/examples/figures/redundant_encoding.png +0 -0
  31. plotastro-1.1.0/examples/make_reference_figures.py +211 -0
  32. plotastro-1.1.0/examples/tutorial.ipynb +1900 -0
  33. {plotastro-1.0.0 → plotastro-1.1.0}/pyproject.toml +4 -2
  34. {plotastro-1.0.0 → plotastro-1.1.0}/requirements-dev.txt +1 -0
  35. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/__init__.py +9 -5
  36. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/_authors.py +1 -1
  37. plotastro-1.1.0/src/plotastro/_colors.py +523 -0
  38. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/_core.py +95 -9
  39. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/_extras.py +38 -3
  40. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/aanda.mplstyle +8 -1
  41. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/apj.mplstyle +8 -1
  42. plotastro-1.1.0/src/plotastro/styles/euclid.mplstyle +126 -0
  43. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/jcap.mplstyle +8 -1
  44. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/mnras.mplstyle +8 -1
  45. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/natastro.mplstyle +8 -1
  46. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/oja.mplstyle +8 -1
  47. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/prd.mplstyle +8 -1
  48. {plotastro-1.0.0 → plotastro-1.1.0}/src/plotastro/styles/rasti.mplstyle +8 -1
  49. {plotastro-1.0.0 → plotastro-1.1.0}/tests/test_authors.py +10 -0
  50. plotastro-1.1.0/tests/test_colors.py +180 -0
  51. plotastro-1.1.0/tests/test_docs.py +46 -0
  52. {plotastro-1.0.0 → plotastro-1.1.0}/tests/test_sizing.py +2 -1
  53. plotastro-1.1.0/tests/test_styles.py +161 -0
  54. plotastro-1.1.0/tools/generate_styles.py +363 -0
  55. plotastro-1.0.0/CHANGELOG.md +0 -48
  56. plotastro-1.0.0/examples/figures/example_column.png +0 -0
  57. plotastro-1.0.0/examples/figures/example_full.png +0 -0
  58. plotastro-1.0.0/examples/figures/redundant_encoding.png +0 -0
  59. plotastro-1.0.0/examples/make_reference_figures.py +0 -90
  60. plotastro-1.0.0/examples/tutorial.ipynb +0 -1281
  61. plotastro-1.0.0/src/plotastro/_colors.py +0 -227
  62. plotastro-1.0.0/tests/test_colors.py +0 -64
  63. plotastro-1.0.0/tests/test_styles.py +0 -69
  64. plotastro-1.0.0/tools/generate_styles.py +0 -202
  65. {plotastro-1.0.0 → plotastro-1.1.0}/.github/workflows/ci.yml +0 -0
  66. {plotastro-1.0.0 → plotastro-1.1.0}/.github/workflows/publish.yml +0 -0
  67. {plotastro-1.0.0 → plotastro-1.1.0}/LICENSE +0 -0
  68. {plotastro-1.0.0 → plotastro-1.1.0}/examples/authors_example.csv +0 -0
  69. {plotastro-1.0.0 → plotastro-1.1.0}/examples/figures/cvd_check.png +0 -0
  70. {plotastro-1.0.0 → plotastro-1.1.0}/examples/figures/linestyles.png +0 -0
  71. {plotastro-1.0.0 → plotastro-1.1.0}/examples/figures/markers.png +0 -0
  72. {plotastro-1.0.0 → plotastro-1.1.0}/examples/figures/palette.png +0 -0
  73. {plotastro-1.0.0 → plotastro-1.1.0}/examples/figures/palette_okabe_ito.png +0 -0
  74. {plotastro-1.0.0 → plotastro-1.1.0}/requirements.txt +0 -0
  75. {plotastro-1.0.0 → plotastro-1.1.0}/tests/conftest.py +0 -0
  76. {plotastro-1.0.0 → plotastro-1.1.0}/tests/test_extras.py +0 -0
@@ -6,3 +6,8 @@ build/
6
6
  *.egg-info/
7
7
  .pytest_cache/
8
8
  .venv/
9
+ docs/_build/
10
+ docs/_figures/
11
+ docs/tutorial.ipynb
12
+ .vscode/
13
+ .DS_Store
@@ -0,0 +1,17 @@
1
+ # Read the Docs configuration — https://docs.readthedocs.io/en/stable/config-file/v2.html
2
+ version: 2
3
+
4
+ build:
5
+ os: ubuntu-24.04
6
+ tools:
7
+ python: "3.12"
8
+
9
+ sphinx:
10
+ configuration: docs/conf.py
11
+ fail_on_warning: false
12
+
13
+ python:
14
+ install:
15
+ - method: pip
16
+ path: .
17
+ - requirements: docs/requirements.txt
@@ -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.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
+ [![PyPI](https://img.shields.io/pypi/v/plotastro.svg)](https://pypi.org/project/plotastro/)
31
+ [![conda-forge](https://img.shields.io/conda/vn/conda-forge/plotastro.svg)](https://anaconda.org/conda-forge/plotastro)
32
+ [![Python versions](https://img.shields.io/pypi/pyversions/plotastro.svg)](https://pypi.org/project/plotastro/)
33
+ [![CI](https://github.com/BehnoodBandi/plotastro/actions/workflows/ci.yml/badge.svg)](https://github.com/BehnoodBandi/plotastro/actions/workflows/ci.yml)
34
+ [![Docs](https://readthedocs.org/projects/plotastro/badge/?version=latest)](https://plotastro.readthedocs.io)
35
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](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** and **Nature Astronomy** — figures at exactly the right physical
32
- size, a colour-blind-friendly palette, and helpers that make the tedious
33
- parts (sizing, panel labels, accessibility checks, saving) one-liners.
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
@@ -66,7 +77,8 @@ pa.savefig("myplot") # -> myplot.pdf, ready for \includegraphics
66
77
  |---|---|
67
78
  | ![single-column example](examples/figures/example_column.png) | ![full-width example](examples/figures/example_full.png) |
68
79
 
69
- **Start with the [tutorial notebook](examples/tutorial.ipynb)** — it walks
80
+ **Full documentation: [plotastro.readthedocs.io](https://plotastro.readthedocs.io)** —
81
+ or start with the [tutorial notebook](examples/tutorial.ipynb), which walks
70
82
  through every feature with runnable examples.
71
83
 
72
84
  ## Why this exists
@@ -85,9 +97,11 @@ Two problems ruin most paper figures:
85
97
 
86
98
  The styles share one visual language — Times-like serif fonts at ~9 pt with
87
99
  ~8 pt tick lettering, inward ticks on all four sides with minors, a subtle
88
- grid, frameless legends — and differ only in figure width (plus the
100
+ grid, legends on a translucent white background — and differ only in figure width (plus the
89
101
  sans-serif fonts Nature requires), so your plots stay **consistent between
90
- 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).
91
105
 
92
106
  ## Supported journals
93
107
 
@@ -104,6 +118,7 @@ papers** no matter where you submit.
104
118
  | `prd` (`prl`, `revtex`) | Physical Review D | 246.0 pt = 3.40 in | 510.0 pt = 7.06 in |
105
119
  | `jcap` | J. Cosmology & Astroparticle Phys. | single-column ≈455 pt = 6.30 in | — |
106
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) |
107
122
  | `thesis` | A4 thesis text width | 426.8 pt = 5.91 in | — |
108
123
  | `beamer` | Beamer slide text width | 307.3 pt = 4.25 in | — |
109
124
 
@@ -112,8 +127,37 @@ document, put `\the\columnwidth` or `\the\textwidth` in your `.tex` body,
112
127
  compile, read the value off the page, and pass it directly:
113
128
  `pa.figsize(width=345.0)`.
114
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
+
115
157
  The only hard dependency is matplotlib; plotastro works with both NumPy 1.x
116
- and 2.x (CI tests each). Running the examples from a clone?
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?
117
161
  `pip install -r requirements-dev.txt`.
118
162
 
119
163
  ## Tutorial
@@ -165,20 +209,77 @@ ax.fill_between(x, lo, hi, color=pa.lighten(pa.COLORS["blue"], 0.7))
165
209
  pa.darken(pa.COLORS["orange"], 0.3) # the other direction
166
210
  ```
167
211
 
168
- Three more palettes ship with the package:
212
+ More palettes ship with the package:
169
213
 
170
214
  - `pa.OKABE_ITO` — [Okabe & Ito (2008)](https://jfly.uni-koeln.de/color/),
171
215
  *the* classic CVD-safe recommendation for categorical colours in science;
172
216
  - `pa.PETROFF10` — [Petroff (2021)](https://arxiv.org/abs/2107.02270), the
173
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;
174
223
  - `pa.PAIRED` — light/dark pairs for data/model or before/after comparisons:
175
224
  `pa.PAIRED["blue"]` → `("#a6cee3", "#1f78b4")`.
176
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
+
177
239
  **Colormaps:** the styles default to `viridis` (perceptually uniform,
178
240
  CVD-safe). Good picks: `viridis`/`magma`/`cividis` for sequential data,
179
241
  `RdBu_r` or `coolwarm` for diverging data (red–*blue*, not red–green). Avoid
180
- `jet`/`rainbow`. For more astro-friendly maps see
181
- [cmasher](https://cmasher.readthedocs.io) and [cmocean](https://matplotlib.org/cmocean/).
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
+ ![CMasher colours and colormaps](examples/figures/cmasher.png)
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.
182
283
 
183
284
  ### Checking accessibility yourself
184
285
 
@@ -270,9 +371,10 @@ your manuscript (custom macros, real kerning):
270
371
  pa.set_style("mnras", usetex=True) # needs latex + dvipng + ghostscript
271
372
  ```
272
373
 
273
- This loads the `newtx` Times fonts (matching the MNRAS/A&A house font), or
274
- Helvetica for Nature Astronomy. Develop with `usetex=False`, flip it on for
275
- the final version — LaTeX rendering is slow.
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.
276
378
 
277
379
  ### Saving figures
278
380
 
@@ -354,14 +456,16 @@ complete example.
354
456
 
355
457
  | | |
356
458
  |---|---|
357
- | `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`) |
358
460
  | `authorlist(csv, journal=)` | LaTeX author/affiliation block from a CSV (CLI: `plotastro-authors`) |
359
461
  | `figsize(width, journal=, fraction=, aspect=, ...)` | journal-correct figure dimensions |
360
462
  | `subplots(...)` | `plt.subplots` with the size computed for you |
361
463
  | `savefig(name, formats=("pdf",))` | save one figure in several formats |
362
464
  | `label_panels(axes, ...)` | (a), (b), (c) panel labels |
363
465
  | `style_cycler(markers=, linestyles=)` | redundant-encoding property cycle |
364
- | `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) |
365
469
  | `lighten(c, f)`, `darken(c, f)` | matched shades without transparency |
366
470
  | `simulate_cvd`, `check_colors`, `check_figure` | colour-vision-deficiency checks |
367
471
  | `MARKERS`, `LINESTYLES` | curated marker / dash-pattern sequences |
@@ -402,7 +506,7 @@ python tools/generate_styles.py # regenerate styles/ after editing the templ
402
506
  python examples/make_reference_figures.py # regenerate README figures
403
507
  ```
404
508
 
405
- The `.mplstyle` files are generated from a single template in
509
+ The `.mplstyle` files are generated from the templates in
406
510
  [tools/generate_styles.py](tools/generate_styles.py) — edit that, not the
407
511
  files (CI checks they stay in sync). Releases: bump the version in
408
512
  `pyproject.toml` and `CHANGELOG.md`, then push a `v*` tag — the
@@ -412,12 +516,20 @@ files (CI checks they stay in sync). Releases: bump the version in
412
516
  ## Credits
413
517
 
414
518
  - Original MNRAS style this grew from:
415
- [M. Knabenhans' mplstyle_for_MNRAS](https://github.com/mischakn/mplstyle_for_MNRAS)
519
+ [M. Knabenhans' mplstyle_for_MNRAS](https://github.com/miknab/mplstyle_for_MNRAS)
416
520
  - Colour-blind-friendly Set1 ordering:
417
521
  [Thøger Rivera-Thorsen](https://gist.github.com/thriveth/8560036);
418
522
  light colours from Tableau *Color Blind 10*
419
523
  - Palettes: [Okabe & Ito](https://jfly.uni-koeln.de/color/),
420
- [Petroff (2021)](https://arxiv.org/abs/2107.02270), ColorBrewer *Paired*
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
421
533
  - CVD model: Machado, Oliveira & Fernandes (2009), IEEE TVCG 15(6)
422
534
  - Figure-size approach after
423
535
  [Jack Walton's guide](https://jwalton.info/Embed-Publication-Matplotlib-Latex/)