plotstyle¶
Publication-ready scientific figures: one line of code.
PlotStyle is a Python library for researchers who use Matplotlib to produce figures for academic publication. It encodes the formatting requirements of major scientific journals into preset configurations: font families, column widths, line weights, DPI, color accessibility rules, and export formats. You apply them with a single call.
import plotstyle
with plotstyle.use("nature") as style:
fig, ax = style.figure(columns=1)
ax.plot([0, 1, 2], [0.2, 0.8, 0.4])
style.savefig(fig, "figure1.pdf")
The context manager sets Matplotlib’s rcParams for the duration of the block and restores them on exit. Everything produced inside - figures, colors, exports - conforms to the journal’s guidelines automatically.
Who it is for¶
PlotStyle is designed for:
Researchers preparing figures for peer-reviewed journal submission
Lab groups that want a consistent, reproducible styling workflow
Anyone who needs clean Matplotlib figures without manual rcParams configuration
It works as a thin, unopinionated wrapper around Matplotlib and is compatible with Seaborn.
Key capabilities¶
Journal presets¶
plotstyle.use("nature") applies the full style configuration for the selected journal: fonts, figure widths, minimum line weights, DPI, and export requirements. Settings are scoped to the context block and do not persist into the rest of your session.
Correct figure dimensions¶
style.figure(columns=1) and style.subplots(nrows, ncols, columns=2) produce figures at the exact column width the journal specifies, in millimeters, converted to the right unit for Matplotlib. Multi-panel figures automatically receive panel labels (a, b, c) formatted according to the journal’s own style.
Overlays¶
Overlays are additive patches that extend or override journal settings. Stack them in any order:
with plotstyle.use(["nature", "okabe-ito", "notebook"]) as style:
...
Overlays are organized into five categories:
Category |
Examples |
|---|---|
Color |
|
Context |
|
Rendering |
|
Script |
|
Plot type |
|
You can also use overlays without a journal preset, for example to style notebook figures or slide graphics.
Colorblind-safe palettes¶
style.palette(n=4) returns colors from the journal’s recommended palette. Built-in palettes include Okabe-Ito, several Tol variants, and a grayscale-safe set. Pass with_markers=True to get (color, linestyle, marker) tuples for journals that require grayscale compatibility.
Accessibility previews¶
plotstyle.preview_colorblind(fig) renders your figure under three types of color vision deficiency (deuteranopia, protanopia, tritanopia). plotstyle.preview_grayscale(fig) shows a luminance-based grayscale version. Use these before submitting.
Pre-submission validation¶
style.validate(fig) checks your figure against the journal’s requirements: dimensions, font sizes, line weights, color accessibility, and export settings. It returns a structured report with pass, warn, and fail states, and suggested fixes for each issue.
Export for submission¶
style.savefig(fig, "figure1.pdf") enforces TrueType font embedding and the journal’s minimum DPI. style.export_submission(fig, "fig1", output_dir="submission/") saves in all formats the journal accepts in one call. IEEE submissions can include an author surname prefix automatically.
Spec comparison and figure migration¶
plotstyle.diff("nature", "science") shows every requirement that differs between two journals. plotstyle.migrate(fig, from_journal="nature", to_journal="science") resizes and re-styles an existing figure for the target journal, with proportional text rescaling.
Seaborn compatibility¶
plotstyle.patch_seaborn() monkey-patches sns.set_theme() so it no longer overwrites PlotStyle’s rcParams. Call plotstyle.unpatch_seaborn() to restore the original behavior.
CLI¶
Discover presets, check fonts, and validate files without writing Python:
plotstyle list # all supported journals
plotstyle info nature # Nature's full spec
plotstyle diff nature science # compare two journals
plotstyle fonts --journal ieee # check font availability
plotstyle overlays --category color
plotstyle validate figure1.pdf --journal nature # check font embedding
Supported journals¶
Key |
Journal |
Publisher |
|---|---|---|
|
ACM |
ACM |
|
ACS (JACS) |
American Chemical Society |
|
Cell |
Cell Press |
|
Elsevier |
Elsevier |
|
IEEE Transactions |
IEEE |
|
Nature |
Springer Nature |
|
PLOS ONE |
Public Library of Science |
|
Physical Review Letters |
American Physical Society |
|
Science |
AAAS |
|
Springer |
Springer |
|
USENIX |
USENIX Association |
|
Wiley |
Wiley |
Where to start¶
New to PlotStyle? Follow this path:
Installation: install the package and optional dependencies
Quickstart: create your first journal figure in five minutes
Concepts: understand how presets, overlays, and context managers work together
For the complete function reference, see the API reference. For per-journal details and formatting requirements, see Journals.
Getting Started
User Guide
Reference
- API Reference
- Style:
plotstyle.core.style - Figures:
plotstyle.core.figure - Export:
plotstyle.core.export - Migration:
plotstyle.core.migrate - Palettes:
plotstyle.color.palettes - Accessibility:
plotstyle.color.accessibility - Grayscale:
plotstyle.color.grayscale - Validation:
plotstyle.validation - Registry:
plotstyle.specs - Overlays:
plotstyle.overlays - Units:
plotstyle.specs.units - Font Engine:
plotstyle.engine.fonts - Preview:
plotstyle.preview - Seaborn Integration:
plotstyle.integrations.seaborn - Warnings:
plotstyle._utils.warnings
- Style:
- CLI Reference