calamari.style#

Journal figure styles: column-width figures that match a target journal.

A publication figure has to satisfy a page it will never be drawn on: its width is the journal’s column, its lettering has to survive reduction to that width, and its colours have to remain distinguishable where the print edition is greyscale. Getting that right by hand means looking up the same handful of numbers for every paper. This module records them once per journal, as evidenced specifications, and turns them into matplotlib rcParams so that every calamari.plot helper – which creates its figure through pyplot when ax is omitted – comes out at column width with nothing else changed.

Alongside calamari.plot, this is the only module permitted to import matplotlib (PK-1, PL-1 in docs/ARCHITECTURE.md); it touches no measurement, so the analysis layers stay free of plotting concerns.

Two orthogonal choices make a style. The journal fixes the geometry (single- and double-column widths and the lettering size the journal asks for at final size); the look fixes everything else (font family, tick convention, colour cycle, colour map). Every journal names a default look, so the common call is one word:

>>> import calamari
>>> calamari.style.use("jpcm")
>>> ax = calamari.plot.plot_mh(m)
>>> calamari.plot.save(ax, "fig1.pdf")               # 8.5 cm wide, 600 dpi

"jpcm:sans" selects a different look; context() scopes the style to a block; figure() builds a correctly sized multi-panel figure. Nothing here changes what a calamari.plot helper draws – only the page it is drawn on.

The numbers are the journals’ own and are cited on each JournalSpec. Where a publisher states a figure width rather than a measured text width (IOP’s 15 cm “large figure”), the stated number is used and the provenance says so; a figure sized to a publisher’s stated width is what the publisher asked for, whatever the page later turns out to measure.

Module attributes

DEFAULT_ASPECT

height ratio of a single-axes figure.

JOURNALS

Registered journals by name; extend with register_journal().

LOOKS

Registered looks by name; extend with register_look().

Functions

available

Registered journal and look names, for discovery and error messages.

context

Apply a journal style inside a with block only.

figure

Create a journal-sized figure and axes, styled, in one call.

panel_labels

Letter a figure's panels (a), (b), .

rc

The rcParams for a journal and look, as a plain dict.

register_journal

Add (or replace) a journal in the registry, with its aliases.

register_look

Add (or replace) a look; use("jpcm:<name>") then selects it.

use

Apply a journal style to the current matplotlib session.

Classes

JournalSpec

The page geometry a journal asks figures to be prepared for.

LookSpec

Everything about a style that is not page geometry.