feat: add DensityMap trace for the MapLibre map subplot#416
Open
jqnatividad wants to merge 4 commits into
Open
feat: add DensityMap trace for the MapLibre map subplot#416jqnatividad wants to merge 4 commits into
jqnatividad wants to merge 4 commits into
Conversation
Add choropleth map support (addresses plotly#408): - `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. `geojson` accepts a URL string or an inline GeoJSON object. - `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. Attribute names/types follow the plotly.js v3.6.0 plot-schema. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The embedded choropleth example calls GeoResolution::OneOverFiftyMillion, but the shared import block omitted GeoResolution, so copying the documented imports alongside the example would not compile. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the modern MapLibre-based `densitymap` trace type, the density counterpart to `ChoroplethMap`. It draws a weighted kernel-density heatmap from lat/lon points (optional per-point weight z) onto the `layout.map` subplot, with full color-scale (colorscale, colorbar, showscale, reversescale, autocolorscale, coloraxis, zmin/zmax/zmid) and hover (text, hovertext, hoverinfo, hovertemplate, hoverlabel, customdata) support. Unlike ChoroplethMap it has no marker/selection. Registers the trace: DensityMap variant on PlotType (serializes to "densitymap"), module + type re-exports in traces/mod.rs and lib.rs. Includes a serialize_density_map unit test and a doctest. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 5, 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.
Summary
plotly.rs has
ChoroplethMapfor the modern MapLibremapsubplot (layout.map), but no density-heatmap trace for it. plotly.js providesdensitymapas the MapLibre-based successor to the (Mapbox-based, now deprecated)densitymapbox. This PR adds a matchingDensityMapRust trace.Closes #414.
DensityMapis drawn on the MapLibremapsubplot introduced in #410, so this PR is stacked on top of #410 and should be reviewed/merged after it. Until #410 merges, the diff here also shows #410's commits; once #410 lands inmain, this diff reduces to just theDensityMapaddition. (Depends on #410.)What changed
New
DensityMap<Lat, Lon, Z>trace mirroringChoroplethMap's structure with a density data model (nomarker/selected/unselected— density traces have none):lat,lon,z(per-point weight),radius,opacityzauto,zmin/zmax/zmid,colorscale,autocolorscale,reversescale,showscale,colorbar,coloraxistext,hovertext,hoverinfo,hovertemplate,hovertemplatefallback,hoverlabelsubplot(defaults to"map"),below,ids,meta,customdata,uirevisionRegistration: a
DensityMapvariant onPlotType(serializes to"densitymap"), plus module/type re-exports intraces/mod.rsandlib.rs. Includes aserialize_density_mapunit test and a doctest.Testing
cargo test -p plotly—serialize_density_mapand its doctest pass.cargo clippy --features all -- -D warnings -A deprecated— clean.cargo +nightly fmt --all -- --check— clean.🤖 Generated with Claude Code