Replace matplotlib with Altair and add live charts to docs#305
Conversation
…Lite charts Switch all visualization examples from matplotlib to Altair for a more declarative, interactive charting experience. Add mkdocs-charts-plugin to render Vega-Lite specs directly in the docs so readers can see live, interactive charts with tooltips—not just code blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @chekos's task in 2m 40s —— View job PR Review: Replace matplotlib with Altair and add live charts to docs
SummaryThis is a well-motivated change — replacing matplotlib with Altair and embedding live Vega-Lite charts significantly improves the docs UX. The infrastructure setup (mkdocs-charts-plugin, CDN scripts, custom fence) is correct. However, there are several issues that need attention before merging. Issues Found🔴 Bug: Wide-format output + tidy-column field name mismatch (
|
| Priority | File | Issue |
|---|---|---|
| 🔴 Bug | migration-flows.md |
"estimate:Q" → "MOVEDNET:Q" in wide-format example |
| 🟡 Confusing | Multiple files | Live charts show different data than the code above them |
| 🟡 Missing dep | pyproject.toml |
altair not in docs dependencies |
| 🟡 Incomplete data | quickstart.md, decennial-data.md |
DC missing from choropleth data |
- Add `altair` to docs optional dependencies in pyproject.toml - Add DC (id: 11) to choropleth datasets in quickstart, decennial, and population-estimates pages that were missing it - Add `!!! example` admonitions above all rendered vegalite charts to clarify they show state-level sample data, not the exact output of the code above them - Update chart titles to remove "(sample data)" suffix now that admonitions explain the context Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @chekos's task in 1m 20s —— View job PR Review Update: Replace matplotlib with Altair and add live charts to docs
All Key Issues Resolved ✅This update addresses every item flagged in the previous review. Here's the status:
Details
Chart/code alignment — Each embedded
DC coverage — All three choropleth charts ( Remaining Minor ItemsThese two items remain but are low-priority and don't block merging:
This PR is in good shape. The Altair patterns are clean and idiomatic, the live chart integration is set up correctly, and all the substantive issues from the prior review have been addressed. |
The lockfile was out of sync with pyproject.toml after adding mkdocs-charts-plugin and altair to the docs extras. ReadTheDocs uses `uv sync --frozen` which requires the lockfile to match. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @chekos's task in 3m 0s —— View job PR Review: Replace matplotlib with Altair and add live charts to docs
Status: All Prior Issues Resolved — One New Issue FoundThe two issues flagged as "still open" in the previous review remain unaddressed (version pinning), and one new bug has been identified that wasn't in prior reviews. New Issue:
|
| Priority | File | Issue |
|---|---|---|
| 🟡 | pyproject.toml |
mkdocs-charts-plugin has no version constraint — a breaking release could silently break all live charts. Consider "mkdocs-charts-plugin>=0.0,<1". |
| 🟢 | mkdocs.yml |
Vega CDN URLs (vega@5, vega-lite@5, vega-embed@6) pin major only. Fine for standard practice, but worth noting for reproducibility. |
What's Working Well
- All critical issues from prior reviews have been resolved:
"MOVEDNET:Q"fix inmigration-flows.md,altairadded to docs deps, DC (id: 11) added to all choropleth datasets, and admonitions added to clarify chart/code scope mismatches. - The Vega-Lite inline data values are accurate (cross-checked against real Census figures).
- The
multi-year.mdline chart remains the cleanest example — data matches the code perfectly. - Zero remaining
matplotlib/plt.references confirmed. - Infrastructure (
mkdocs-charts-plugin, customvegalitefence, CDN scripts) is set up correctly.
| Branch
Documents project structure, common commands, dependency management (including the uv.lock gotcha with ReadTheDocs), docs conventions, CI pipeline, and test markers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @chekos's task in 1m 16s —— View job PR Review: Replace matplotlib with Altair and add live charts to docs
Status: One Bug Still OpenThe PR was synchronized by adding Still Open:
|
| Priority | File | Issue |
|---|---|---|
| 🟡 | pyproject.toml |
mkdocs-charts-plugin has no version constraint — a breaking release could silently break all live charts. Consider "mkdocs-charts-plugin>=0.0,<1". |
| 🟢 | mkdocs.yml |
Vega CDN URLs (vega@5, vega-lite@5, vega-embed@6) pin major only — standard practice, but worth noting for reproducibility. |
What's Working Well
CLAUDE.mdis a nice addition with clear project setup and conventions.- All critical issues from the first two reviews are resolved:
"MOVEDNET:Q"fix,altairin docs deps, DC (id: 11) in all choropleth datasets, admonitions for chart/code scope differences. - Zero remaining
matplotlib/plt.references. - Infrastructure (
mkdocs-charts-plugin,vegalitefence, CDN scripts) is correct.
| Branch
Altair cannot resolve nested attribute access like geometry.x in field references. Extract lon/lat into separate columns before passing to alt.Chart(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude finished @chekos's task in 54s —— View job PR Review: Replace matplotlib with Altair and add live charts to docs
All Issues Resolved ✅The # Extract point coordinates for Altair.
dots = dots.copy()
dots["lon"] = dots.geometry.x
dots["lat"] = dots.geometry.y
alt.Chart(dots).mark_circle(size=1, opacity=0.6).encode(
longitude="lon:Q", # ✅ plain column reference
latitude="lat:Q", # ✅ plain column reference
...Full Issue Tracker
Remaining Low-Priority ItemsThese two items don't block merging:
SummaryThis PR is in great shape. Zero remaining |
Summary
mkdocs-charts-pluginto render interactive Vega-Lite charts directly in the docs (choropleth maps, line charts) so readers see live visualizations—not just code blocksChanges
Infrastructure
pyproject.toml— Addedmkdocs-charts-pluginto docs dependenciesmkdocs.yml— Addedchartsplugin,extra_javascriptfor Vega/Vega-Lite/Vega-Embed CDN, andvegalitecustom fenceDocumentation (8 files)
docs/guides/spatial.md— Replaced matplotlib choropleth & dot density code with Altair + live choroplethdocs/guides/multi-year.md— Replaced matplotlib line chart with Altair + live interactive line chartdocs/getting-started/quickstart.md— Replaced.plot()with Altair + live US choroplethdocs/guides/acs-data.md— Replaced.plot()with Altairmark_geoshape()docs/guides/decennial-data.md— Replaced.plot()with Altair + live 2020 Census choroplethdocs/guides/population-estimates.md— Replaced.plot()with Altair + live population choroplethdocs/guides/migration-flows.md— Replaced.plot()with Altairdocs/migration/from-tidycensus.md— Updated comparison table and code exampleTest plan
mkdocs buildto verify no build errors with the new charts pluginmkdocs serveand check that Vega-Lite charts render interactively on the spatial, multi-year, quickstart, decennial, and population estimates pagesmatplotlib/plt.references in docs:grep -r "matplotlib\|plt\." docs/🤖 Generated with Claude Code