Add Choropleth and ChoroplethMap trace types#410
Merged
Conversation
jqnatividad
added a commit
to dathere/plotly
that referenced
this pull request
Jul 1, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 1, 2026
14bc447 to
f2d6c2c
Compare
- add `Choropleth<Loc, Z>` on the existing `geo` subplot, with a `LocationMode` enum (ISO-3 / USA-states / country names / geojson-id), a dedicated `choropleth::Marker`, selection support, z-bounds, and the shared `ColorScale`/`ColorBar` machinery. - add `ChoroplethMap<Loc, Z>`, the plotly.js 3.x `choroplethmap` trace on the MapLibre `map` subplot (GeoJSON-only). - new MapLibre `map` subplot via `LayoutMap` + `MapStyle` + `MapBounds`. - `LayoutGeo` additions: `fitbounds` (`GeoFitBounds`), `resolution` (`GeoResolution`, 1:110M/1:50M base-layer detail), and `bgcolor`. - `PlotType::Choropleth`/`ChoroplethMap` variants, re-exports, serialization tests, doctests, runnable `examples/maps` examples, and a Maps book recipe. - the new attribute names/types follow the plotly.js v3.6.0 plot-schema. - docs(book): add GeoResolution to choropleth recipe imports Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
f2d6c2c to
aaf1add
Compare
Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
e733abf to
7bd5202
Compare
andrei-ng
approved these changes
Jul 8, 2026
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.
resolves #408
What's added
Trace types
Choropleth<Loc, Z>— classic choropleth on the existinggeosubplot (LayoutGeo). Includes aLocationModeenum (ISO-3/USA-states/country names/geojson-id), a dedicatedchoropleth::Marker(region-boundaryline+opacity),Selection/SelectionMarker, z-bounds, and the sharedColorScale/ColorBarmachinery.geojsonaccepts a URL string or an inline GeoJSON object (serde_json::Value).ChoroplethMap<Loc, Z>— the modern plotly.js 3.xchoroplethmaptrace on the MapLibremapsubplot (GeoJSON-only).Layout
LayoutMap+MapStyle+MapBounds— the MapLibremapsubplot, which the crate did not have before (onlymapbox). Mirrors the existingMapboxsubplot and is wired intoLayout.LayoutGeoenhancements for the classicgeosubplot:fitbounds(GeoFitBounds:false/locations/geojson) — auto-frames the subplot to the plotted data, overridingcenter/lonaxis/lataxiswhen set.resolution(GeoResolution:OneOverOneHundredTenMillion→110default,OneOverFiftyMillion→50) — selects base-layer detail. Per plotly.js, the value is the scale denominator (110= 1:110,000,000), so50gives higher-detail coastlines/land/borders. Pairs naturally with the UN geodata that became the plotly.js v3.1.0 default (bundled plotly.js is 3.6.0).bgcolor— background color of thegeosubplot.Plumbing, tests, docs
PlotType::Choropleth/PlotType::ChoroplethMapvariants and top-level + sub-module re-exports.examples/maps(choropleth+choropleth_map), and a new Maps → Choropleth Maps book recipe page.Verification
cargo build --features all;cargo clippy --features all -- -D warnings -A deprecatedclean.cargo test -p plotly— 315 lib tests + doctests pass (the 8 failing tests are the pre-existing browser-export ones needing chromedriver).examples/mapsbuilds and lints clean;cargo +nightly fmt --all -- --checkclean in both workspaces.Notes
plot-schema.json(traces.choropleth,traces.choroplethmap,layout.map).mapsis intentionally not added to the automated book-example build because itsmain()performs a network fetch (scatter_geo) and isn't part of CI'sBOOK_EXAMPLES.PlotTypevariants + new layout/trace fields generate newRestyle*/Relayout*enum variants), so this targets the next breaking release (0.15.0), consistent with the other in-flight work.🤖 Generated with Claude Code