Violin plot
A violin plot mirrors a density curve on both sides of a centre line, showing the full shape of each group's distribution, including multiple peaks that a box plot would hide.
When to use it
- Groups may be bimodal or skewed.
- Each group has enough data for a smooth density (30+ points).
Watch out: With small samples the smoothed shape is mostly invented. Use points or a box plot.
Ask for it in pltchat
Upload your file and type something like:
"violin plot of reaction time by condition, show medians"
pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.
The matplotlib code
Self-contained with example data; swap in pd.read_csv(...) or
pd.read_excel(...) for your own file.
import numpy as np
import matplotlib.pyplot as plt
rng = np.random.default_rng(11)
data = [rng.normal(450, 60, 200),
np.r_[rng.normal(400, 40, 100), rng.normal(560, 40, 100)],
rng.gamma(9, 55, 200)]
labels = ["Baseline", "Dual task", "Fatigue"]
fig, ax = plt.subplots(figsize=(6.4, 4))
ax.violinplot(data, showmedians=True, quantiles=[[0.25, 0.75]] * 3)
ax.set_xticks([1, 2, 3], labels)
ax.set_ylabel("Reaction time (ms)")
ax.spines[["top", "right"]].set_visible(False)
plt.tight_layout()
plt.show()
Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.