This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
matthewplotlib is a terminal-based plotting library for Python that renders charts using Unicode characters (braille, box drawing) with ANSI color codes. Plots are composable expressions combined via operators (+ for hstack, / for vstack). Outputs to terminal via print() or to PNG/GIF via an embedded pixel font.
# Install (use uv for package management)
uv pip install -e ".[dev]"
# Run tests
pytest tests/ -v # or: make test
pytest tests/test_colors.py::TestParseColorNamed::test_named_colors -v # single test
# Type checking (primary quality gate)
mypy matthewplotlib/
# Regenerate API docs
make DOCS.mdSix core modules in matthewplotlib/:
- core.py —
CharArraydataclass: the fundamental rendering primitive (grid of unicode chars with optional fg/bg RGB). Handles ANSI escape codes, composition (stacking/layering/padding), PIL image rendering, and GIF export. - plots.py — All plot types inherit from base
plotclass (provides height/width, render methods, operator overloads). Categories: data plots (scatter, image, bars, histogram, etc.), furnishings (text, border, axes), and arrangement (hstack, vstack, wrap, center, blank). - data.py —
Series/Series3types for flexible plot input parsing. Accepts arrays, tuples, axis objects. Includesproject3()for 3D-to-2D camera projection. - colormaps.py — Continuous colormaps (viridis, magma, etc.) and discrete palettes (sweetie16, pico8, tableau). Types:
ContinuousColorMap,DiscreteColorMap. - colors.py —
Color/ColorLiketypes,parse_color()supporting named colors, hex, int/float RGB tuples. - unscii16.py — Embedded UNSCII-16 bitmap font data for image export (do not edit manually).
Public API is aggregated in __init__.py. New features must be exported there.
From CONTRIBUTING.md — before merging any branch:
mypy matthewplotlib/passespytest tests/ -vpasses (includes integration tests for all examples)make DOCS.mdis up to date- Look through README and make sure it's up to date, including roadmap section.
- Update CHANGELOG.md
- Export new features in
__init__.py
See CONTRIBUTING.md for instructions on how to prepare a new version for release.
# # #/# Titlecomment blocks are used for code folding — preserve this pattern when adding new sections- CHANGELOG entries should be concise and describe API-level changes, not implementation details
- Build backend: Hatchling
- Python: >= 3.10
- Core deps: numpy, einops, numpy-hilbert-curve, Pillow
- Version is tracked in both
pyproject.tomlandmatthewplotlib/__init__.py(must be bumped together)