Choropleth plotting - #429
Merged
Merged
Conversation
Add a reusable `choropleth()` function for rendering spatial maps of per-region quantities from GeoDataFrames or custom value arrays. Includes comprehensive test coverage and a Jupyter notebook demonstrating both single and multi-panel usage patterns.
No additional project dependencies. ffmpeg use optional for .mp4 output.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds reusable choropleth plotting utilities to laser.core (static and animated) and introduces a dedicated test suite plus changelog documentation for the new functionality.
Changes:
- Add
laser.core.plotting.choropleth()for static choropleth rendering with optional log scaling and optional fixed color scale (vmin/vmax). - Add
laser.core.plotting.animate_choropleth()+_save_animation()to render a sequence of frames with a shared color scale and multiple output formats (GIF/HTML/ffmpeg-backed video). - Add comprehensive tests for both helpers and document the feature in
CHANGELOG.rst.
Reviewed changes
Copilot reviewed 3 out of 7 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/laser/core/plotting.py |
New choropleth + animated choropleth helpers (plus writer-selection save helper). |
tests/test_plotting.py |
New tests validating static/animated choropleths, IO paths, and error handling. |
CHANGELOG.rst |
Documents the new plotting capabilities in the Unreleased section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add input validation at API boundaries in `choropleth()` and `animate_choropleth()` to reject invalid inputs with clean, actionable error messages instead of leaking low-level NumPy, matplotlib, or geopandas exceptions. New validations: - Non-numeric columns/values raise `TypeError` naming the dtype - Ragged `values_by_frame` raises `ValueError` instead of NumPy's "setting an array element with a sequence" error - `log=True` with values `<= -1` raises `ValueError` (log1p undefined there) instead of silently plotting `-inf`/`NaN` Include comprehensive regression tests and improved docstrings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #201