LabCanvas
Free account · save your work, full figure editorSign up free

Box plot and violin plot maker with statistics

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.

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 pointwithin 1.5×IQRViolin (Gaussian KDE):h=0.9⋅min(SD,IQR/1.34)⋅n−1/5Welch:t=x¯1−x¯2s12/n1+s22/n2
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.

Last updated

FreeNo sign-upRuns in your browserData analysis

Loading Box plot and violin plot maker…

At a glance

Box plot and violin plot maker at a glance
InputOne column per group (names in the first row), or group name and value in two columns
Box plotMedian, Q1–Q3 (linear interpolation), whiskers to 1.5×IQR, outliers
ViolinGaussian KDE, Silverman bandwidth 0.9⋅min(SD,IQR/1.34)⋅n−1/5
TestsWelch t, Mann–Whitney U (exact without ties), one-way ANOVA + Tukey–Kramer, Kruskal–Wallis + Dunn (Holm)
AccuracyStatistics and p-values match SciPy
ExportSVG and 300 dpi PNG plot; CSV summary and tests
Runs inYour web browser; nothing is uploaded
PriceFree, no account needed

What it does

How to use the box plot and violin plot maker

  1. Paste the groupsCopy 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 testChoose 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 exportRead the p-value, the pairwise comparisons and the summary table, then download the plot as SVG or PNG and the statistics as CSV.

How it works

Box plot. The box runs from the first quartile (Q1) to the third (Q3) with a line at the median; the interquartile range is IQR=Q3−Q1. 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 Q1−1.5×IQR and Q3+1.5×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)∑φ((x−xi)/h), with Silverman’s rule-of-thumb bandwidth h=0.9⋅min(SD,IQR/1.34)⋅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=x¯1−x¯2s12/n1+s22/n2df=(s12/n1+s22/n2)2(s12/n1)2n1−1+(s22/n2)2n2−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: U1=R1−n1(n1+1)/2, where R1 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=(|U−n1n2/2|−0.5)/σU.

Three or more groups. One-way ANOVA:

F=∑ni(x¯i−x¯)2/(k−1)∑∑(x−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=|x¯i−x¯j|MSwithin/2⋅(1/ni+1/nj)

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

H=12N(N+1)∑Ri2ni−3(N+1)

divided by the tie correction 1−∑(t3−t)/(N3−N), with p from χ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, χ2, normal and studentised range distributions are those of the LabCanvas Graphs app, validated against SciPy and R; they reproduce the table values t0.975,10=2.228, F0.95;2,12=3.885, χ0.95,22=5.991, z0.975=1.960 and q0.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. 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. 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. McGill R, Tukey JW, Larsen WA. Variations of box plots. Am Stat 1978;32:12–16, doi: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. 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. 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.

Summary table from the tool
GroupnMeanSDMedianQ1–Q3 (IQR)Outliers
Vehicle8983183.6960.5870.5–1040.75 (170.25)1350
Drug A8667.584.0671.5612.5–718.75 (106.25)none
Drug B8529.4208.2455406.25–542.5 (136.25)1010

Box plot by hand (vehicle). Sorted: 768, 812, 890, 945, 976, 1020, 1103, 1350. Q1 is at position 1+7×0.25=2.75, between 812 and 890: 812+0.75×78=870.5. The median is (945+976)/2=960.5 and Q3=1020+0.25×83=1040.75, so IQR=170.25. The upper fence is 1040.75+1.5×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×min(183.6,170.25/1.34) ×8−1/5=75.4 mm3.

Three groups, parametric. One-way ANOVA gives F(2,21)=15.42, p=0.000076 (η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 183.62/8+84.02/8=71.39, so t=(983−667.5)/71.39=4.42 with 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.

Which test the tool uses
Roughly normal dataSkewed data, scores, outliers
2 groupsWelch’s t-testMann–Whitney U test
3 or more groupsOne-way ANOVA + Tukey–KramerKruskal–Wallis + Dunn (Holm)

Not sure which test fits your design (paired data, counts, correlations)? Use the statistical test chooser.

Frequently asked 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×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 Q1−1.5×IQR or above Q3+1.5×IQR (Tukey’s fences). It is a flag to check the value, not a reason to delete it.

What do the stars mean?

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

Make the full figure

The LabCanvas Graphs app draws box, violin and dot plots with the same tests plus paired and repeated-measures designs, two-way ANOVA and more, styled for journals.

Open the Graphs app