Note
Go to the end to download the full example code.
Violin inner annotations
inner overlays a summary of the raw data inside each violin: "box" for
an IQR bar with 1.5-IQR whiskers and a median dot, "quartile" for lines
across the density at Q1/median/Q3, or "stick" for one line per
observation.

Live figure — pick a tool, then zoom, pan, point-pick or annotate. Nothing is active until a tool is selected.
View this figure’s Vega export ↗ — the raw JSON spec, rendered live by a real Vega engine.
View this figure’s Vega-Lite export ↗ — the raw JSON spec(s), rendered live by a real Vega-Lite engine.
import numpy as np
import plotpress
rng = np.random.default_rng(7)
groups = [
rng.normal(5.0, 0.35, 300),
rng.normal(5.9, 0.52, 300),
rng.normal(6.6, 0.64, 300),
]
names = ["setosa", "versicolor", "virginica"]
fig, axes = plotpress.subplots(1, 3, figsize=(12.0, 4.0), sharey=True)
for ax, inner in zip(axes, ["box", "quartile", "stick"]):
ax.violinplot(groups, cut=2.0, inner=inner)
ax.set_xticks([1, 2, 3])
ax.set_xticklabels(names)
ax.set_title(f'inner="{inner}"')
axes[0].set_ylabel("sepal length (cm)")
fig.tight_layout()
Total running time of the script: (0 minutes 0.197 seconds)