# Box plot and violin plot maker with statistics

> Paste groups, get a box plot or violin plot with every point, Welch t, Mann–Whitney, ANOVA or Kruskal–Wallis p-values and brackets. SVG, PNG, CSV.

URL: https://www.labcanvas.com/tools/box-plot-maker

Paste your groups (one column each, straight from Excel) and the tool draws a box plot (median, quartiles, 1.5 × IQR whiskers and outliers) or a violin plot (Gaussian kernel density) with every data point shown. It tests the groups: Welch’s t-test or the Mann–Whitney U test for two groups, one-way ANOVA with Tukey–Kramer or Kruskal–Wallis with Dunn’s test for three or more, and adds significance brackets with stars or p-values. A summary table gives n, mean, SD, SEM, median and IQR, and the plot downloads as SVG or 300 dpi PNG.

## Quick answer

- **What it does:** Draws a box plot or violin plot of pasted groups with every point jittered, tests the groups (Welch t / Mann–Whitney, ANOVA / Kruskal–Wallis) and adds significance brackets.
- **Formula:** Box: Q1, median, Q3 (linear interpolation), whiskers to the last point within 1.5 × IQR; violin: Gaussian KDE, h = 0.9 · min(SD, IQR/1.34) · n^(−1/5); Welch t = (x̄₁ − x̄₂) / √(s₁²/n₁ + s₂²/n₂).
- **Example:** Tumour volumes of 8 vehicle mice (mean 983 mm³, SD 183.6) vs 8 Drug A mice (mean 667.5, SD 84.0): Welch t(9.80) = 4.42, p = 0.0014; Mann–Whitney U = 63, exact p = 0.00031.

Free, in the browser, no account needed. Updated 2026-10-19.

## Features

- Box plot (Tukey: median, quartiles, whiskers to \(1.5 \times \mathrm{IQR}\), outliers), violin plot, or violin with a box inside
- Every data point shown, jittered, so small samples are not hidden behind a box
- Violins from a Gaussian kernel density estimate with Silverman’s rule-of-thumb bandwidth, trimmed to the data range
- 2 groups: Welch’s t-test (with the 95% CI of the difference) or Mann–Whitney U (exact p without ties)
- 3 or more groups: one-way ANOVA with Tukey–Kramer comparisons, or Kruskal–Wallis with Dunn’s test (Holm-adjusted)
- Significance brackets with stars (* \(p \lt 0.05\) … **** \(p \lt 0.0001\)) or exact p-values, significant only or all pairs
- Summary table: n, mean, SD, SEM, median, Q1, Q3, IQR, min, max, outliers and a Shapiro–Wilk normality p per group
- Colour-blind-safe Okabe–Ito colours; SVG and 300 dpi PNG plot, CSV of the statistics; nothing is uploaded

## How to use it

1. **Paste the groups**: Copy your columns from Excel or Prism with the group names in the first row. A two-column list of group name and value also works.
2. **Pick the plot and the test**: Choose box, violin or both, and Welch t / ANOVA for roughly normal data or Mann–Whitney / Kruskal–Wallis for skewed data, scores or outliers.
3. **Read and export**: Read the p-value, the pairwise comparisons and the summary table, then download the plot as SVG or PNG and the statistics as CSV.

## At a glance

| | |
| --- | --- |
| Input | One column per group (names in the first row), or group name and value in two columns |
| Box plot | Median, Q1–Q3 (linear interpolation), whiskers to \(1.5 \times \mathrm{IQR}\), outliers |
| Violin | Gaussian KDE, Silverman bandwidth \(0.9 \cdot \min(\mathrm{SD}, \mathrm{IQR}/1.34) \cdot n^{-1/5}\) |
| Tests | Welch t, Mann–Whitney U (exact without ties), one-way ANOVA + Tukey–Kramer, Kruskal–Wallis + Dunn (Holm) |
| Accuracy | Statistics and p-values match SciPy |
| Export | SVG and 300 dpi PNG plot; CSV summary and tests |

## How it works

**Box plot.** The box runs from the first quartile (\(Q_1\)) to the third (\(Q_3\)) with a line at the median; the interquartile range is \(\mathrm{IQR} = Q_3 - Q_1\). Quartiles use linear interpolation between ordered values (the default in R, NumPy and Excel’s QUARTILE.INC): with \(n\) values sorted, the \(p\)-th quantile sits at position \(1 + (n - 1)p\). Whiskers reach the most extreme values within \(Q_1 - 1.5 \times \mathrm{IQR}\) and \(Q_3 + 1.5 \times \mathrm{IQR}\), and points beyond are outliers (Tukey’s rule; McGill, Tukey and Larsen 1978).

**Violin plot.** A violin is a box plot with the density of the data drawn on both sides (Hintze and Nelson 1998). The density is a Gaussian kernel estimate \(f(x) = (1 / nh) \sum \varphi((x - x_i) / h)\), with Silverman’s rule-of-thumb bandwidth \(h = 0.9 \cdot \min(\mathrm{SD}, \mathrm{IQR} / 1.34) \cdot n^{-1/5}\) (Silverman 1986, eq. 3.31; the default in R’s `density()` and ggplot2’s `geom_violin`). Each violin is scaled to the same maximum width and cut at the smallest and largest value.

**Two groups.** Welch’s t-test compares means without assuming equal variances, with Welch–Satterthwaite degrees of freedom (Welch 1947):

$$t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_1^2/n_1 + s_2^2/n_2}}$$

$$\mathrm{df} = \frac{(s_1^2/n_1 + s_2^2/n_2)^2}{\frac{(s_1^2/n_1)^2}{n_1 - 1} + \frac{(s_2^2/n_2)^2}{n_2 - 1}}$$

It is the better default than Student’s t-test, losing little power when variances are equal (Delacre et al. 2017). The Mann–Whitney U test ranks all values together: \(U_1 = R_1 - n_1(n_1 + 1)/2\), where \(R_1\) is the rank sum of group 1 (Mann and Whitney 1947). Without ties the p-value is exact, from the null distribution of \(U\); with ties it uses the normal approximation with tie and continuity corrections, \(z = (\lvert U - n_1 n_2/2\rvert - 0.5) / \sigma_U\).

**Three or more groups.** One-way ANOVA:

$$F = \frac{\sum n_i(\bar{x}_i - \bar{x})^2 / (k - 1)}{\sum\sum (x - \bar{x}_i)^2 / (N - k)}$$

with \(p\) from the F distribution with \((k - 1, N - k)\) degrees of freedom; pairs are compared with the Tukey–Kramer test,

$$q = \frac{\lvert \bar{x}_i - \bar{x}_j \rvert}{\sqrt{\mathrm{MS}_\mathrm{within}/2 \cdot (1/n_i + 1/n_j)}}$$

with \(p\) from the studentised range distribution. Kruskal–Wallis:

$$H = \frac{12}{N(N + 1)} \sum \frac{R_i^2}{n_i} - 3(N + 1)$$

divided by the tie correction \(1 - \sum (t^3 - t)/(N^3 - N)\), with \(p\) from \(\chi^2\) with \(k - 1\) degrees of freedom (Kruskal and Wallis 1952); pairs are compared with Dunn’s z test on mean ranks, Holm-adjusted. All tests are two-sided.

**Accuracy.** The t, F, \(\chi^2\), normal and studentised range distributions are those of the LabCanvas Graphs app, validated against SciPy and R; they reproduce the table values \(t_{0.975,\,10} = 2.228\), \(F_{0.95;\,2,\,12} = 3.885\), \(\chi^2_{0.95,\,2} = 5.991\), \(z_{0.975} = 1.960\) and \(q_{0.95;\,3,\,21} = 3.565\). Every statistic and p-value in the worked example matches SciPy 1.18 to 8 or more significant figures.

Sources: Welch BL. The generalization of ‘Student’s’ problem when several different population variances are involved. *Biometrika* 1947;34:28–35, [doi:10.1093/biomet/34.1-2.28](https://doi.org/10.1093/biomet/34.1-2.28). Mann HB, Whitney DR. On a test of whether one of two random variables is stochastically larger than the other. *Ann Math Stat* 1947;18:50–60, [doi:10.1214/aoms/1177730491](https://doi.org/10.1214/aoms/1177730491). Kruskal WH, Wallis WA. Use of ranks in one-criterion variance analysis. *J Am Stat Assoc* 1952;47:583–621, [doi:10.1080/01621459.1952.10483441](https://doi.org/10.1080/01621459.1952.10483441). McGill R, Tukey JW, Larsen WA. Variations of box plots. *Am Stat* 1978;32:12–16, [doi:10.1080/00031305.1978.10479236](https://doi.org/10.1080/00031305.1978.10479236). Hintze JL, Nelson RD. Violin plots: a box plot-density trace synergism. *Am Stat* 1998;52:181–184, [doi:10.1080/00031305.1998.10480559](https://doi.org/10.1080/00031305.1998.10480559). Delacre M, Lakens D, Leys C. Why psychologists should by default use Welch’s t-test instead of Student’s t-test. *Int Rev Soc Psychol* 2017;30:92–101, [doi:10.5334/irsp.82](https://doi.org/10.5334/irsp.82). Silverman BW. *Density Estimation for Statistics and Data Analysis*. London: Chapman & Hall; 1986.

## Worked example: tumour volume in three groups of mice

The built-in data are tumour volumes (mm³) of three groups of 8 mice: vehicle, Drug A and Drug B.

| Group | n | Mean | SD | Median | Q1–Q3 (IQR) | Outliers |
| --- | --- | --- | --- | --- | --- | --- |
| Vehicle | 8 | 983 | 183.6 | 960.5 | 870.5–1040.75 (170.25) | 1350 |
| Drug A | 8 | 667.5 | 84.0 | 671.5 | 612.5–718.75 (106.25) | none |
| Drug B | 8 | 529.4 | 208.2 | 455 | 406.25–542.5 (136.25) | 1010 |

**Box plot by hand (vehicle).** Sorted: 768, 812, 890, 945, 976, 1020, 1103, 1350. \(Q_1\) is at position \(1 + 7 \times 0.25 = 2.75\), between 812 and 890: \(812 + 0.75 \times 78 = 870.5\). The median is \((945 + 976) / 2 = 960.5\) and \(Q_3 = 1020 + 0.25 \times 83 = 1040.75\), so \(\mathrm{IQR} = 170.25\). The upper fence is \(1040.75 + 1.5 \times 170.25 = 1296.1\), so 1350 is drawn as an outlier and the whisker stops at 1103. The violin’s Silverman bandwidth is \(h = 0.9 \times \min(183.6, 170.25 / 1.34)\) \(\times\, 8^{-1/5} = 75.4\ \mathrm{mm^3}\).

**Three groups, parametric.** One-way ANOVA gives \(F(2, 21) = 15.42\), \(p = 0.000076\) (\(\eta^2 = 0.59\)). Tukey–Kramer: vehicle vs Drug A \(p = 0.0031\) (**), vehicle vs Drug B \(p = 0.000064\) (****), Drug A vs Drug B \(p = 0.25\) (ns).

**Three groups, non-parametric.** Kruskal–Wallis \(H(2) = 14.61\), \(p = 0.00067\) (mean ranks 19.75, 11.38 and 6.38). Dunn’s test, Holm-adjusted: vehicle vs Drug A \(p = 0.036\) (*), vehicle vs Drug B \(p = 0.00046\) (***), Drug A vs Drug B \(p = 0.16\) (ns). The outliers weigh less in the rank test, but the conclusion is the same.

**Two groups.** Delete the Drug B column to compare vehicle and Drug A only. Welch’s t-test: the standard error is \(\sqrt{183.6^2/8 + 84.0^2/8} = 71.39\), so \(t = (983 - 667.5) / 71.39 = 4.42\) with \(\mathrm{df} = 9.80\), \(p = 0.0014\); the difference is 315.5 mm³ (95% CI 156.0 to 475.0). Mann–Whitney: vehicle has a rank sum of 99, so \(U = 99 - 36 = 63\) of a possible 64, and the exact two-sided \(p = 0.00031\).

|  | Roughly normal data | Skewed data, scores, outliers |
| --- | --- | --- |
| 2 groups | Welch’s t-test | Mann–Whitney U test |
| 3 or more groups | One-way ANOVA + Tukey–Kramer | Kruskal–Wallis + Dunn (Holm) |

Not sure which test fits your design (paired data, counts, correlations)? Use the [statistical test chooser](https://www.labcanvas.com/tools/statistical-test-chooser).

## Questions

### How do I make a box plot with p-values?

Paste one column per group with names in the first row, pick Welch t / ANOVA (normal data) or Mann–Whitney / Kruskal–Wallis (skewed data), and the plot shows brackets with stars or p-values between the groups that differ. Download it as SVG or a 300 dpi PNG.

### What do the whiskers of a box plot show?

Here, and in most software (R, ggplot2, Prism’s “Tukey” option), the whiskers reach the most extreme data points within \(1.5 \times \mathrm{IQR}\) of the box. Points beyond are outliers. Some figures instead draw whiskers to the minimum and maximum or to percentiles, so say which in the legend.

### Box plot or violin plot: which should I use?

A box plot summarises five numbers and works for any sample size. A violin also shows the shape of the distribution, such as two peaks, but needs more data (about 20 or more values per group) to be meaningful. With small n, show every point on top of either one.

### Should I use a t-test or Mann–Whitney?

Use Welch’s t-test when each group is roughly normal or the groups are large (about 30 or more). Use Mann–Whitney for scores, strongly skewed data or outliers with small groups. Decide before looking at the p-values; the test chooser helps.

### Why Welch’s t-test instead of Student’s t-test?

Welch’s test does not assume the two groups have equal variances. When they are equal it gives almost the same result as Student’s test, and when they differ it keeps the false-positive rate correct, so it is the safer default.

### Why not run t-tests between every pair of 3 groups?

Each extra test adds a chance of a false positive. ANOVA or Kruskal–Wallis tests all groups at once, and Tukey–Kramer or Dunn’s test with Holm adjustment compares the pairs while keeping the overall error at 5%.

### How is an outlier defined in a box plot?

A point below \(Q_1 - 1.5 \times \mathrm{IQR}\) or above \(Q_3 + 1.5 \times \mathrm{IQR}\) (Tukey’s fences). It is a flag to check the value, not a reason to delete it.

### What do the stars mean?

* \(p \lt 0.05\), ** \(p \lt 0.01\), *** \(p \lt 0.001\), **** \(p \lt 0.0001\) and ns not significant (\(p \ge 0.05\)), the convention used by GraphPad Prism. Switch to p-values to show the exact numbers.
