Skip to content

feat: add Violin trace type (stacked on choropleth)#3

Open
jqnatividad wants to merge 14 commits into
feat/choropleth-maps-upstreamfrom
feat/choropleth-violin
Open

feat: add Violin trace type (stacked on choropleth)#3
jqnatividad wants to merge 14 commits into
feat/choropleth-maps-upstreamfrom
feat/choropleth-violin

Conversation

@jqnatividad

Copy link
Copy Markdown

Summary

Stacks the Violin trace type on top of feat/choropleth-maps-upstream so downstream consumers (qsv) can use violin plots today, while the upstream contribution is reviewed separately.

This branch = feat/choropleth-maps-upstream + the same violin commit, cherry-picked with the additive PlotType/lib.rs re-export conflicts resolved to keep both choropleth and violin.

What's included

Same as the upstream PR: Violin<X, Y> with the full plotly.js violin attribute surface (bandwidth, box, meanline, span/spanmode, scalegroup/scalemode, side, points/jitter/pointpos, selected/unselected, quartilemethod, hoveron, zorder, x0/y0), supporting types, tests, a statistical_charts example, and a book recipe.

Verification

  • cargo test -p plotly --features static_export_chromedriver violin → 12 passed
  • Cherry-pick conflicts resolved (keep both choropleth + violin registrations)

🤖 Generated with Claude Code

RedZapdos123 and others added 14 commits July 1, 2026 16:49
…plotly#402)

When checking out the repository fresh and running `cargo check` at the workspace root, compilation fails because `plotly_static` has no driver features enabled by default.

This PR makes `plotly_static` and `potly` crates compile without a webdriver requirement. However a webdriver needs to be selected to export static plots at runtime.


Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>

---------

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
Co-authored-by: RedZapdos123 <redzapdos123@example.com>
Co-authored-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
Add the `Violin` trace with the full plotly.js violin attribute surface:
bandwidth, box (inner mini box plot), meanline, KDE span/spanmode,
scalegroup/scalemode, side (split violins), points/jitter/pointpos,
selected/unselected, quartilemethod, hoveron, and zorder.

Grouped and split violins work via the existing `ViolinMode` layout
attribute. Includes unit tests, a doctest, a statistical-charts example
(basic, horizontal, split), and a book recipe.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the placeholder box_plot.png thumbnail for the Violin Plots recipe
with a generated 1024x680 violin image, and add the plotly#412 reference to the
CHANGELOG entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Type the violin `span` field as `NumOrStringCollection` instead of
`Vec<f64>`. Plotly.js types `span` as an `info_array` of `any`, so
date/category axis values must be allowed for manual KDE spans on
non-numeric value axes. Numeric spans continue to work unchanged; add a
test covering both numeric and date-string spans.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extend the DensityMapbox trace with the hover, data-array, and
color-control attributes it was missing relative to the plotly.js
densitymapbox reference:

- hover/text: text, hovertext, hoverinfo, hovertemplate,
  hovertemplatefallback, hoverlabel
- data/misc: ids, meta, customdata, uirevision, below
- color: colorscale, autocolorscale, reversescale, showscale,
  colorbar, coloraxis

The FieldSetter derive generates the scalar and *_array builder
setters (e.g. hover_text/hover_text_array), so per-point hover text
and shared colorscales are now expressible. Existing fields are
unchanged. Extends the serialize_density_mapbox test to cover the
new keys.

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>
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>
…races

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `ScatterMap`, the MapLibre-based counterpart to `ScatterMapbox`, drawn
on the `layout.map` subplot (`LayoutMap`/`MapStyle`). It mirrors
`ScatterMapbox` field-for-field — markers/lines, `Fill`/`Selection`, and the
full hover set (text/hovertext/hoverinfo/hovertemplate/customdata/hoverlabel)
— but emits `"type": "scattermap"` and references `layout.map`.

Add a `PlotType::ScatterMap` variant, re-export `ScatterMap` and the
`scatter_map` module, and add a `serialize_scatter_map` unit test plus a doc
example.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md
#	plotly/src/lib.rs
Add a `Cluster` option to the MapLibre `ScatterMap` trace, exposing
plotly.js's `scattermap.cluster` attributes (`enabled`, `color`,
`maxzoom`, `opacity`, `size`, `step`). Clustering groups nearby markers
client-side (MapLibre supercluster) into bubbles that expand into
individual points on zoom, decluttering dense point maps without
dropping any data.

This is a `scattermap`-only feature; the deprecated `ScatterMapbox` has
no equivalent. Stacked on the ScatterMap trace addition (plotly#417).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants