Markers, line styles and panel labels¶
Markers and dash patterns that stay distinguishable at journal sizes, a cycler that pairs them with colours, and panel labels. See Markers, line styles and panel labels for the guide.
Markers and line styles¶
- plotastro.MARKERS: list[str]¶
A marker sequence that stays distinguishable at small sizes:
["o", "s", "^", "D", "v", "p", "*", "X"]
- plotastro.LINESTYLES: dict[str, str | tuple]¶
Named dash patterns beyond matplotlib’s built-ins. The tuples are matplotlib
(offset, (on, off, ...))dash specs, which scale with the line width and print cleanly. Use them asls=pa.LINESTYLES["long dash"].{"solid": "-", "dashed": (0, (5, 2)), "dotted": (0, (1, 1.5)), "dashdot": (0, (5, 2, 1, 2)), "long dash": (0, (9, 3)), "dash dot dot": (0, (5, 2, 1, 2, 1, 2)), "densely dotted": (0, (1, 0.8)), "loosely dashed": (0, (5, 6))}
- plotastro.show_markers()[source]¶
Reference chart of
MARKERS(first row) and eight more matplotlib markers, each with the code that draws it.- Return type:
Figure
- plotastro.show_linestyles()[source]¶
Reference chart of the named dash patterns in
LINESTYLES.- Return type:
Figure
Cycling colours, markers and dashes together¶
- plotastro.style_cycler(n=None, *, colors=True, markers=False, linestyles=False)[source]¶
Build a property cycler that pairs colours with markers and/or dash patterns, so lines stay distinguishable in greyscale and for colour-blind readers (redundant encoding).
- Parameters:
- Returns:
cycler.Cycler (for
ax.set_prop_cycleor)plt.rc("axes", prop_cycle=...). The colours are always thedefault cycle,
COLORS.
Examples
>>> ax.set_prop_cycle(pa.style_cycler(markers=True)) >>> ax.set_prop_cycle(pa.style_cycler(linestyles=True)) >>> plt.rc("axes", prop_cycle=pa.style_cycler(markers=True)) # globally
To pair markers with colours from another palette, build the cycle
yourself, e.g.
plt.cycler(color=pa.cmasher_colors("torch", n=4)) + plt.cycler(marker=pa.MARKERS[:4]).
Panel labels¶
- plotastro.label_panels(axes, fmt='({})', loc='upper left', uppercase=False, labels=None, **text_kw)[source]¶
Stamp (a), (b), (c), … on a grid of subplots, the way most journals want multi-panel figures labelled.
- Parameters:
axes (Axes, sequence of Axes, or array from plt.subplots) – Labelled in the order given (arrays are flattened row-major).
fmt (str, optional) – Applied to each letter; e.g.
"({})"-> “(a)”,"{}."-> “a.”.loc (str, optional) – One of “upper left”, “upper right”, “lower left”, “lower right”, or “outside” (above the top-left corner — the Nature convention, usually combined with
fmt="{}"and bold text).uppercase (bool, optional) – Use A, B, C instead of a, b, c.
labels (sequence of str, optional) – Explicit labels, overriding the alphabet.
**text_kw – Forwarded to
ax.text(e.g.fontweight="bold").
- Return type:
list of the Text objects created.
Examples
>>> fig, axes = pa.subplots(2, 2, width="full") >>> pa.label_panels(axes) >>> pa.label_panels(axes, loc="outside", fmt="{}", fontweight="bold")