Violin Plot vs Box Plot: Differences, Sample Sizes & Rules
2026/11/28

Violin Plot vs Box Plot: Differences, Sample Sizes & Rules

Choosing between a violin plot vs box plot comes down to distribution shape versus concise summary statistics. A box plot displays five summary values and explicit outliers, while a violin plot mirrors a Kernel Density Estimate (KDE) to reveal multiple peaks and skew. Use a box plot with raw points for small groups, and a violin or raincloud plot when larger samples may hide subpopulations.

Compare a violin plot and a Tukey box plot on your own data. Try the free Violin Plot Maker → Vizcept is an AI scientific figure generator whose browser-based tool renders violin and box plots with code, supporting optional raw points, bandwidth controls, and watermark-free editable SVG or 300 DPI PNG downloads.

How Do Violin Plot and Box Plot Anatomy Differ?

A box plot encodes exact order statistics across five key points (minimum, Q1, median, Q3, and maximum), whereas a violin plot mirrors a smoothed density curve around a central axis.

In a Tukey box plot, the box spans the Interquartile Range (IQR = Q3 − Q1) from Q1 (25th percentile) to Q3 (75th percentile), holding the middle 50% of values around the median (Q2, 50th). In Matplotlib pyplot.boxplot (whis=1.5) and R boxplot.stats (coef=1.5), whiskers stop at the furthest observed values inside Q1 − 1.5 × IQR and Q3 + 1.5 × IQR; points outside plot as outliers (fliers).

Whisker rules vary by standard. The NIST Handbook draws basic whiskers to sample min and max, while its outlier guide flags values past 1.5 × IQR as mild and past 3 × IQR as extreme outliers (abnormally distant points, not automatic errors).

Introduced by Hintze and Nelson (1998), a violin plot rotates a KDE curve 90 degrees and mirrors it symmetrically. Width shows estimated density, not sample count. While Seaborn violinplot adds an inner box (inner='box'), Matplotlib pyplot.violinplot defaults to showmedians=False, showmeans=False, and showextrema=True, leaving only the density outline and extrema bars.

Core structural differences among a box plot, a violin plot, and a raincloud plot include:

FeatureBox Plot (Tukey)Violin Plot (KDE)Raincloud Plot
EncodingQ1, median, Q3, whiskers, fliersMirrored KDE curveHalf-violin + points + box
BimodalityHidden inside IQRVisible modes & valleysVisible peaks + raw points
OutliersExplicit (1.5 × IQR)Stretched thin tailsRaw points + fliers
Sample size (n)Hidden unless addedHidden unless scaled/pointedEvery point visible
SmoothingNone (quartile rule only)High (bandwidth & cut)Cloud only; points raw
Best rangeUnimodal (+ points if n < 100)Rule of thumb: n >= 30 (clearest >= 100)Medium-to-large cohorts

What Can a Violin Plot Reveal That a Box Plot Hides?

A violin plot exposes bimodal subpopulations, clusters, and gaps that share identical medians and IQRs in a box plot. When groups mix responders and non-responders, or distinct cell states, a five-number summary flattens two peaks into one rectangle.

Choonpradub and McNeil showed that box plots lose shape whenever data depart from one peak. Three n = 80 groups sharing nearly identical Q1, median, Q3, and whiskers (unimodal normal, bimodal, and uniform) yield nearly identical box plots, while violins separate the central bulge, pinched waist, and flat shoulders immediately.

Side-by-side comparison of three n=80 distributions (unimodal, bimodal, uniform) showing near-identical Tukey box plots beside distinct violin plot density shapes

Are violin plots better than box plots?

No. Treating a violin plot as an automatic upgrade over a box plot hurts clarity in many scientific papers. Swapping to a bare violin removes explicit 1.5 × IQR outlier dots, stretches extreme values into narrow tips, and implies smooth density that small samples cannot support.

For skew checks and fast group comparisons, a box plot stays easier to scan: an off-center median line and unequal whisker lengths flag skewness at a glance, whereas a violin plot shows how steeply the long tail tapers. Inspect both views during exploration, keep a box plot for unimodal groups where specific outliers matter, and switch to a violin with inner quantiles when multimodality alters the conclusion.

What Sample Size Do You Need for a Violin Plot vs a Box Plot?

No single minimum sample size separates valid from invalid violin plots, because KDE accuracy depends on group size (n) and true shape. Peer-reviewed guidelines divide n into practical ranges instead.

In a KDE bandwidth-selection benchmark across n = 15 to 2,000, accuracy shifted with sample size and density complexity rather than one cutoff. For biomedical papers, Weissgerber et al. (2017, J Biol Chem) recommend univariate dot or scatter plots when n <= 10.

Simulations by Weissgerber et al. (2019, Circulation) across normal, skewed, and bimodal data showed shape was clear at n = 100, hard to judge at n = 20, and impossible at n = 5. The JBMR data guide notes raw points stay resolvable for n < 100 and requires them for small groups.

Practical rule-of-thumb chart choices (not hard statistical cutoffs) by sample size and study design include:

Sample Size / DesignRecommended PlotReason
n <= 10 per groupDot plot, strip chart, or beeswarmToo sparse for KDE or quartiles; show every point.
n = 11 to 29Box plot + jittered/beeswarm pointsGives quantiles without inventing smooth peaks.
n = 30 to 99Violin + inner box + points (or raincloud / SinaPlot)Shows bimodality while keeping raw points verifiable.
n >= 100Violin + inner box/quartiles (or raincloud)Avoids dot overplotting in large cohorts.
Paired / repeatedPaired line plot or within-pair differencesIndependent groups hide subject-level trajectories.

Paired and repeated-measures studies need a separate layout. As Weissgerber et al. (2015, PLOS Biology) and follow-up statistical reporting guidance show, separate pre- and post-treatment boxes or violins hide subject-level trajectories. Connect matched pairs with lines or plot within-pair differences. Under the Nature Reporting Summary, report exact discrete n, units, and independent versus repeated measurements.

How Do You Configure a Violin Plot Without KDE Artifacts?

Configuring an honest violin plot requires setting four parameters: bandwidth, tail truncation (cut / trim), width scaling (density_norm / scale), and interior markers. Unchecked defaults can invent modes, paint density past physical limits, or mask unequal group sizes.

Controlling bandwidth and log-scale skew

Bandwidth sets KDE smoothness. Hintze and Nelson (1998) and a EuroVis 2023 study document two opposing traps: over-smoothing with wide bandwidth merges real peaks into one hump, while under-smoothing with narrow bandwidth turns noise into fake bumps.

The KDE bandwidth-selection benchmark recommends biased cross-validation or Silverman's rule for n = 25–100, and adaptive Sheather–Jones plug-in estimation for larger samples. In Seaborn 0.13.2, bw_method defaults to 'scott' and bw_adjust to 1; test narrower and wider multipliers before finalizing. For skewed assays like RNA-seq counts, log-transform data before KDE estimation.

Fixing tail overflow, width scaling, and R ggplot2 defaults

Tail extension differs between Python and R. Seaborn's default cut=2 extends density two bandwidths past extremes, painting curves below zero on zero-bounded measures like reaction time; cut=0 creates a truncated violin plot confined to sample min and max. In R, ggplot2::geom_violin() defaults to trim = TRUE, bw = "nrd0" (Silverman), adjust = 1, and scale = "area", often paired with + geom_boxplot().

Three-panel KDE diagnostic showing cut=2 tail overflow vs cut=0 truncation, bandwidth 0.20x vs 1.0x vs 2.2x smoothing on bimodal data, and density_norm area vs count scaling for n=15 and n=120

Check two more Seaborn controls before saving. First, density_norm defaults to 'area', giving equal area to n = 15 and n = 120 groups; switch to 'count' to scale width by n, or 'width' for equal peak width, and state the rule in your caption. Second, pair shells with inner='box', 'quart', 'point', or 'stick' to show quantiles or raw observations.

Why Do Quartiles Differ Between R, Python, and Excel Box Plots?

Two box plots from identical numbers can draw different Q1 and Q3 edges because software defaults to different finite-sample quartile algorithms. A shifted edge across tools usually signals an algorithm mismatch rather than a data bug.

R stats::quantile offers nine Hyndman–Fan algorithms (type = 1 to 9, default 7). NumPy percentile() defaults to method='linear' (Type 7). Since version 4.0.3, ggplot2 geom_boxplot() accepts quantile.type from 1 to 9 (default 7).

Base R and Excel depart from Type 7 predictably. Base R boxplot.stats() uses Tukey hinges, matching quartiles for odd n but differing for even n: quartiles fall on observations when n %% 4 == 1, whereas hinges also fall on observations when n %% 4 == 2, taking midpoints otherwise. In Microsoft Excel's Box and Whisker chart, Inclusive median includes the median when N is odd while Exclusive median excludes it, shifting Q1 and Q3 on odd groups.

Default quartile rules across major tools include:

Software / FunctionDefault AlgorithmPractical Difference
R stats::quantile()Hyndman–Fan Type 7Types 1–9 available; differs from base R boxplot() on even n.
Base R boxplot.stats()Tukey hingesMatches odd n; differs on even n (n %% 4 == 2).
R ggplot2::geom_boxplot()Hyndman–Fan Type 7quantile.type configurable since ggplot2 4.0.3.
Python NumPy / MatplotlibLinear interpolation (Type 7)Matches R quantile(type = 7).
Microsoft Excel Box & WhiskerInclusive or Exclusive medianChanges Q1 and Q3 on odd N; state choice in Methods.

When tables and boxes disagree, check the quartile rule first. Researchers can compare four conventions (TI-84 halves, Tukey hinges, Excel Inclusive / R & NumPy Type 7, and Excel Exclusive) with step-by-step math in Vizcept's Box Plot Maker, with free watermark-free SVG and 300 DPI PNG exports.

When Should You Combine Violin and Box Plots or Switch to Alternatives?

Researchers rarely need a plain box plot or a bare violin plot alone. Hybrid layouts combine density shape, quantiles, and raw points while replacing bar-and-error ("dynamite") plots for continuous outcomes.

Raincloud plots, Beeswarm plots, and SinaPlots

Popularized by Allen et al. (Wellcome Open Research), a raincloud plot pairs a half-violin ("cloud"), jittered raw points ("rain"), and a compact box summary. Readers verify n alongside peaks and medians, though the cloud still inherits KDE bandwidth sensitivity.

When individual values matter more than smooth curves, point-based plots skip KDE assumptions. A Beeswarm plot offsets coincident points horizontally without overlap. A SinaPlot (Sidiropoulos et al., 2018) restricts horizontal jitter by normalized density, forming a violin silhouette purely from real points.

Notched box plots and ridgeline plots

Notched box plots draw an interval of roughly ±1.58 × IQR / √n around each median (per R boxplot.stats). Non-overlapping notches offer a rough visual check for median differences at about 95% confidence, though readers must not confuse notches with box bounds or standard error bars.

For many ordered groups (such as expression across timepoints), staggered horizontal densities in ggridges::geom_density_ridges read cleaner than narrow vertical violins. Setting scale=1 lets the tallest peak touch the next baseline; note that ggridges::stat_density_ridges pools bandwidth across the full dataset by default.

Decision tree for choosing among dot/beeswarm plots, box plots with points, violin plots, raincloud plots, paired line plots, and ridgeline plots, alongside a labeled three-layer raincloud plot diagram

How Should You Export Violin and Box Plots for Journal Submission?

Export statistical plots as editable vector files whenever your journal accepts them, sized to final column width before saving. Resizing a raster screenshot blurs tick labels, distorts whiskers, and triggers production rejections.

Major publisher specifications differ sharply across Nature Research Figure Guide (export panels) and PLOS Figure Guidelines:

SpecificationNature Research Figure GuidePLOS Figure Guidelines
Preferred formatEditable vector .ai, .eps, .pdf (plain .svg acceptable)TIFF or EPS only (< 10 MB)
ResolutionVector line art/text (do not rasterize); photos >= 300 dpi (450 dpi rec.)300–600 dpi
Print dimensions89 mm (1-col), 183 mm (2-col), max height 170 mm789–2,250 px wide, max 2,625 px tall (at 300 dpi)
Typography5–7 pt; recommends standard sans-serif (Arial or Helvetica); RGB8–12 pt; Arial, Times, or Symbol

In Python, Matplotlib savefig exports SVG, PDF, EPS, or PNG with explicit dpi and bbox_inches='tight'.

Four caption items to verify before submitting any violin plot vs box plot figure are:

  1. Exact discrete n, unit, and independent versus repeated design per group.
  2. Box and whisker rules (median, Q1–Q3, 1.5 × IQR observed-value whiskers or min–max, quartile method).
  3. KDE settings for violin or raincloud layers (bandwidth or bw_adjust, cut=0/trim, density_norm).
  4. Added overlays (mean marker, ±1.58 × IQR / √n notches, or raw observations).

Frequently Asked Questions

Does Excel have a built-in violin plot, or only a box plot?

Microsoft Excel includes native Box and Whisker and Histogram charts, but it has no built-in violin plot per Microsoft's Office chart list. Paste spreadsheet columns into R, Python, or a browser-based violin plot maker instead of manual area-chart workarounds.

Should you always use a truncated violin plot (cut=0)?

Truncate a violin plot with cut=0 (or trim = TRUE in ggplot2) whenever measurements have a hard physical boundary such as zero-floored concentrations or 0–100% scores. Truncation stops the KDE from implying impossible values past observed extremes, though the interior curve remains smoothed.

Can you read the mean from a box plot or violin plot?

No, a Tukey box plot marks the median rather than the mean, and Matplotlib's default violin plot marks neither. When your test compares means (such as a t-test or ANOVA), overlay an explicit mean symbol and define it in the legend.

Are Vizcept's violin plot and box plot makers free to export without watermarks?

Yes. Pasting columns or opening a CSV in Vizcept's browser-based tools renders locally, and downloading editable Scalable Vector Graphics (SVG) or 300 DPI Portable Network Graphics (PNG) files is free with no watermark and zero credits. Only the optional "Describe with AI" feature uses 2 credits per request.

When is a histogram or dot plot better than both a box plot and a violin plot?

Use a histogram for binned frequency counts on one group without KDE smoothing. Use a dot plot when n <= 10 per group or when integer counts should stay stacked on a number line.

Newsletter

Join the community

Subscribe to our newsletter for the latest news and updates

Featured on Findly.tools