Skip to content

feat: add Violin trace type#412

Open
jqnatividad wants to merge 3 commits into
plotly:mainfrom
dathere:feat/violin-trace-upstream
Open

feat: add Violin trace type#412
jqnatividad wants to merge 3 commits into
plotly:mainfrom
dathere:feat/violin-trace-upstream

Conversation

@jqnatividad

@jqnatividad jqnatividad commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

resolves #411

Adds the Violin trace type, matching the full attribute surface of plotly.js's violin trace.

Violin plots visualize the distribution of numerical data using a kernel density estimate, optionally with an inner box plot, mean line, and sample points.

What's included

  • Violin<X, Y> trace with all violin-specific attributes: bandwidth, box (inner mini box plot), meanline, span/spanmode, scalegroup/scalemode, side (split violins), points/jitter/pointpos, selected/unselected, quartilemethod, hoveron, zorder, x0/y0, plus the standard base-trace attributes.
  • Supporting types: ViolinBox, MeanLine, Selection/SelectionMarker, and enums ViolinPoints, ScaleMode, SpanMode, ViolinSide, HoverOn (reuses box_plot::QuartileMethod).
  • Registration: PlotType::Violin, module + re-exports in traces/mod.rs and lib.rs. Grouped/split violins work via the existing ViolinMode layout attribute.
  • Tests: 12 unit tests + a doctest.
  • Example: statistical_charts gains basic, horizontal, and split violin examples.
  • Book: new Violin Plots recipe under Statistical Charts.

Attribute names were verified against plotly.js src/traces/violin/attributes.js.

Checklist

  • cargo test -p plotly passes (12 violin unit tests + doctest)
  • cargo clippy --features all -- -D warnings -A deprecated clean
  • cargo +nightly fmt --all
  • CHANGELOG.md updated

🤖 Generated with Claude Code

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>
jqnatividad added a commit to dathere/plotly that referenced this pull request Jul 3, 2026
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>
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.

Add violin plot support

1 participant