|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the repository for "Matplotlib for Storytellers", a Python data visualization book that teaches frustrated matplotlib users how to craft good data visuals. The project contains: |
| 8 | + |
| 9 | +- LaTeX source files for the book (main.tex and supporting files in tex/) |
| 10 | +- Python scripts generating matplotlib figures (python/) |
| 11 | +- Generated figure outputs (figures/) |
| 12 | +- Demo Jupyter notebooks (Demos/) |
| 13 | +- Data files for examples (Data/) |
| 14 | + |
| 15 | +## Key Commands |
| 16 | + |
| 17 | +### Building the Book |
| 18 | +```bash |
| 19 | +# Compile the LaTeX book |
| 20 | +pdflatex main.tex |
| 21 | +# Run multiple times if needed for references/TOC |
| 22 | +``` |
| 23 | + |
| 24 | +### Running Python Scripts |
| 25 | +```bash |
| 26 | +# Generate figures - scripts save to figures/ directory |
| 27 | +cd python/ |
| 28 | +python <script-name>.py |
| 29 | +``` |
| 30 | + |
| 31 | +### Common Dependencies |
| 32 | +The project uses these Python libraries: |
| 33 | +- matplotlib |
| 34 | +- numpy |
| 35 | +- pandas |
| 36 | +- scipy |
| 37 | +- scikit-learn (sklearn) |
| 38 | +- ternary (optional, for ternary plots) |
| 39 | + |
| 40 | +## Architecture Notes |
| 41 | + |
| 42 | +1. **Figure Generation**: Python scripts in `python/` generate PDF figures saved to `figures/` subdirectories (mathplots/, poetryplots/, proseplots/, specialplots/) |
| 43 | + |
| 44 | +2. **Book Structure**: The main LaTeX file `main.tex` includes chapters from `tex/` subdirectories: |
| 45 | + - prose/ - Core matplotlib concepts |
| 46 | + - poetry/ - Advanced visualizations |
| 47 | + - math/ - Mathematical interlude |
| 48 | + - special/ - Special topics (MDS, stats, ternary plots) |
| 49 | + |
| 50 | +3. **Style Files**: |
| 51 | + - Custom matplotlib styles in `stylelib/` |
| 52 | + - LaTeX style definitions in `tex/customcolors.sty` and `tex/mplstyle.sty` |
| 53 | + |
| 54 | +4. **Helper Functions**: Some scripts use helper modules like `nyt-helper-data.py`, `rps-br-helper.py`, and `speedo-functions.py` |
| 55 | + |
| 56 | +## Working with Figures |
| 57 | + |
| 58 | +When modifying or creating figures: |
| 59 | +1. Python scripts should save outputs to the appropriate `figures/` subdirectory |
| 60 | +2. Use consistent naming between .py files and their .pdf outputs |
| 61 | +3. Many scripts demonstrate specific matplotlib techniques mentioned in the book text |
| 62 | + |
| 63 | +## Jupyter Book Conversion Guidelines |
| 64 | + |
| 65 | +When converting LaTeX content to Jupyter Book format: |
| 66 | + |
| 67 | +1. **Content Fidelity**: Keep the Jupyter Book content as close as possible to the LaTeX content. The primary goal is preserving the original text, code examples, and educational material. |
| 68 | + |
| 69 | +2. **Acceptable Changes**: |
| 70 | + - Convert LaTeX syntax to Markdown (equations, formatting, etc.) |
| 71 | + - Adjust image paths and convert PDF figures to PNG format |
| 72 | + - Use Markdown-specific features for better web readability |
| 73 | + - Convert LaTeX cross-references to Markdown links |
| 74 | + |
| 75 | +3. **Do NOT**: |
| 76 | + - Abbreviate or summarize content |
| 77 | + - Remove code examples or explanations |
| 78 | + - Change the pedagogical flow or structure |
| 79 | + - Add new content not present in the original LaTeX |
| 80 | + |
| 81 | +4. **Figure Conversion**: Convert all PDF figures to PNG at 300 DPI for web compatibility while maintaining visual quality. |
0 commit comments