Violin Plot
Source: Data Visualisation Catalogue - Violin Plot
Why This Belongs In The Compiler Gallery
Violin plots extend the density plot from one distribution to grouped distributions. They are useful in the compiler gallery because the visible shape is not a primitive mark: the compiler must estimate group density, mirror it around each category center, and emit a path silhouette while preserving lineage back to raw observations.
Data Contract
Each raw row represents one observation in one group.
| Field | Type | Purpose |
|---|---|---|
category | categorical | Group/facet for one violin silhouette. |
score | quantitative | Raw observed measure. |
pathD | text, derived | Mirrored density silhouette emitted by the violin layout. |
median | quantitative, derived | Median for the category. |
q1 / q3 | quantitative, derived | Interquartile guide values. |
bandwidth | quantitative, derived | Kernel bandwidth used for the density estimate. |
Expected Visual
A faithful violin plot should show one mirrored density shape per category. The widest part of each silhouette represents the densest value range. Median and interquartile guides help keep the chart readable as a statistical summary, not only a shape comparison.
| Element | Expected treatment |
|---|---|
| Silhouette | Smooth mirrored density path centered under the category label. |
| Summary guide | Median crossbar and IQR line. |
| Axis | Shared quantitative y-axis. |
| Color | Ordinal color by category. |
| Labels | Category labels below the silhouettes. |
Compiler Mapping
| Compiler part | Mapping |
|---|---|
| Data source | observations and derived violins. |
| Transform | Focused layoutKind: "violin" estimates density, mirrors it, and emits pathD, median, and quartile coordinates. |
| Scales | y: linear, color: ordinal. |
| Layers | Direct path silhouettes plus line median/IQR guides and text category labels. |
| Guides | Generated y-axis and y gridlines. |
Faithfulness Notes
The core mirrored density shape is compiler-owned now. Remaining work is policy breadth: grouped bandwidth controls, optional raw-point overlays, density normalization modes, and collision-aware labels for many categories.