Installation¶
Requirements¶
Python 3.10 or later
Matplotlib 3.9 (installed automatically)
NumPy 1.23 (installed automatically)
PlotStyle supports Python 3.10 through 3.13.
Basic install¶
pip install plotstyle
This installs PlotStyle with its required dependencies: Matplotlib, NumPy, and Cycler. On Python 3.10, tomli is also installed automatically for TOML parsing (Python 3.11+ has this built in).
Verify the install:
import plotstyle
print(plotstyle.__version__)
Optional extras¶
Some features require additional packages. Install them using bracket syntax.
Seaborn integration¶
pip install "plotstyle[seaborn]"
Installs Seaborn and pandas. Required if you call plotstyle.patch_seaborn() or use Seaborn alongside PlotStyle.
Better PDF font subsetting¶
pip install "plotstyle[fonttools]"
Installs fonttools. When present, Matplotlib uses it during savefig to produce better-quality PDF font subsetting. Recommended for final submission exports, especially for journals that require embedded TrueType fonts.
Install all extras¶
pip install "plotstyle[all]"
Installs both seaborn and fonttools.
Feature availability without extras¶
The following features work without any optional extras:
All journal presets and overlays
style.figure(),style.subplots(),style.palette()style.validate()andstyle.savefig()Colorblind and grayscale previews (
preview_colorblind,preview_grayscale)plotstyle.diff()andplotstyle.migrate()The full CLI (
plotstyle list,plotstyle info,plotstyle validate, etc.)
Development install¶
git clone https://github.com/rahulkaushal04/plotstyle.git
cd plotstyle
pip install -e ".[dev]"
The dev extra includes fonttools, Pillow (for image comparison tests), pytest, ruff, mypy, and pre-commit.
Build the docs locally¶
pip install -e ".[docs]"
hatch run docs:build
hatch run docs:serve # serves on http://localhost:8000
Common issues¶
Font not applied¶
If a journal preset specifies a font (such as Helvetica for Nature) that is not installed on your system, PlotStyle falls back to the next available font in the preference list and emits a FontFallbackWarning. To see what fonts a journal requires, run:
plotstyle fonts --journal nature
Install missing fonts at the OS level, then rebuild Matplotlib’s font cache:
from matplotlib.font_manager import _load_fontmanager
_load_fontmanager(try_read_cache=False)
This may take a minute while Matplotlib scans all system fonts. Let it finish.
LaTeX rendering fails¶
If you use latex=True in plotstyle.use() and TeX is not on your PATH, PlotStyle raises an error. Switch to latex=False (uses Matplotlib’s MathText renderer) or add the no-latex overlay:
with plotstyle.use(["nature", "no-latex"]) as style:
...
Matplotlib version conflict¶
PlotStyle requires matplotlib>=3.9,<4. If you see a version conflict, upgrade with:
pip install "matplotlib>=3.9,<4"