Skip to main content
v2026.11,858 entries · CC-BY 4.0

Seaborn Violin Plots: sns.violinplot Syntax, Parameters and Examples

How to make a seaborn violin plot with sns.violinplot: install, split and hue, inner, bandwidth and cut settings, and the 0.13 parameter renames.

Written and maintained by CASRAI Editorial Board

Last updated

A seaborn violin plot draws, for each group, a mirrored kernel density estimate (KDE) of the values, with a box plot summary inside it. You create one with seaborn.violinplot() (or sns.catplot(kind='violin')), and it returns a Matplotlib Axes. Most code found online was written for seaborn versions before 0.13, so this guide lists the current parameters, the three deprecated ones and their replacements, and the settings that decide whether a violin misleads in a research figure.

What a seaborn violin plot is used for in research

The seaborn categorical tutorial describes the violin plot as combining a box plot with the kernel density estimation procedure, which gives a richer description of the distribution of values than a box alone. The quartile and whisker values from the box plot are shown inside the violin. Researchers use it to compare how a measurement is distributed across groups (treatment arms, sites, time points) when the shape of the distribution matters and not only the median.

If you only need the shape of one variable, a histogram is the simpler choice, and that guide compares histograms with density, box and violin plots. For two numeric variables use a scatter plot in Python instead.

Install seaborn (official source)

The seaborn installation page lists these commands:

pip install seaborn
pip install "seaborn[stats]"
conda install seaborn
conda install seaborn -c conda-forge

If Python reports No module named seaborn, use python -m pip install seaborn so pip installs into the same interpreter that runs your code. The seaborn installation page (checked 2026-10-29) lists Python 3.8 or later, with numpy, pandas and matplotlib as required dependencies and statsmodels, scipy and fastcluster as optional ones. The latest version shown on that page is 0.13.2. The [stats] extra adds the optional statistical dependencies.

Step-by-step: make a violin plot with sns.violinplot

The examples below use the tips and titanic datasets that the official documentation uses; both load with sns.load_dataset().

  1. Import and load data.

    import seaborn as sns
    import matplotlib.pyplot as plt
    df = sns.load_dataset("titanic")
  2. Plot one distribution. Pass a single numeric variable and it is drawn as one violin:

    sns.violinplot(x=df["age"])
  3. Compare groups. Put the category on one axis and the numeric variable on the other. Adding hue draws one violin per hue level within each category:

    sns.violinplot(data=df, x="class", y="age", hue="alive")
  4. Split the violins. With split=True each violin shows one hue level on each side, so two levels sit in one shape. The documentation shows it with quartile lines and a gap:

    sns.violinplot(data=df, x="class", y="age", hue="alive", split=True, inner="quart")
    sns.violinplot(data=df, x="class", y="age", hue="alive", split=True, gap=.1, inner="quart")
  5. Use the figure-level function when you need facets. From the tutorial:

    tips = sns.load_dataset("tips")
    sns.catplot(data=tips, x="total_bill", y="day", hue="sex", kind="violin")
  6. Show the individual observations. The tutorial suggests combining a violin plot with a swarm or strip plot, and the documented pattern removes the inner box so the points are not cluttered:

    g = sns.catplot(data=tips, x="day", y="total_bill", kind="violin", inner=None)
    sns.swarmplot(data=tips, x="day", y="total_bill", color="k", size=3, ax=g.ax)

Seaborn plot, plots and plotting: where violin plots sit in seaborn

Seaborn plotting functions come in two kinds. Axes-level functions such as violinplot() draw onto a Matplotlib Axes and return it; figure-level functions such as catplot() create their own figure. Using catplot(kind='violin') gives the same violin as violinplot() but with facet support. To pick colours for the groups, see the guide on seaborn color palettes; for a different seaborn plot type, see heatmaps in seaborn. For how seaborn relates to the library underneath it, see seaborn vs Matplotlib.

Output and how to read it: the parameters that change the picture

Each violin is a KDE, so the figure depends on the smoothing and cut-off settings as well as on the data. These are the parameters from the current seaborn.violinplot documentation that matter most for reporting.

Parameter What the documentation says Why it matters in a research figure
inner Sets what is drawn inside the violin. Options: "box" (default), "quart", "point", "stick", None. "point" and "stick" show each observation, which lets a reader see how many data points sit behind a smooth shape.
density_norm Normalizes each density to set the violin width: "area" (default, equal areas), "count" (width proportional to the number of observations) or "width" (equal widths). The docs example uses density_norm="count" (with inner="point") so that widths reflect group sizes.
cut Distance, in units of bandwidth, to extend the density past the extreme data points. Default 2. cut=0 limits the KDE to the range of the data, so the violin does not extend past the observed minimum and maximum.
bw_adjust Factor that scales the bandwidth to use more or less smoothing. Default 1. The docs and tutorial show bw_adjust=.5 for less smoothing; larger values smooth more and smaller values smooth less.
split Shows an un-mirrored distribution, alternating sides when using hue. Puts two hue levels in a single shape for direct comparison.
fill Draws filled violins by default; fill=False draws outlines (added in 0.13.0). Draws line art instead of a solid patch.

Because the violin uses a KDE, the tutorial notes that some other parameters may need tweaking, namely bw_adjust and cut. The tutorial applies both together: sns.catplot(data=tips, x="total_bill", y="day", hue="sex", kind="violin", bw_adjust=.5, cut=0).

Troubleshooting: deprecations and old tutorial code

Seaborn 0.13.0 renamed three violinplot parameters. Code copied from older tutorials that uses the old names triggers deprecation warnings.

Old parameter Replacement (0.13.0 and later)
scale density_norm
scale_hue common_norm
bw bw_method and bw_adjust

The same release added fill, gap, linecolor, bw_method, bw_adjust, density_norm, common_norm, formatter, log_scale, native_scale, legend and inner_kws. It also changed orient to accept "x" and "y", set the dodge default to "auto", and removed the requirement that split=True has exactly two hue levels. If an example fails with an unexpected-keyword error, check which seaborn version it was written for and compare with sns.__version__.

If import seaborn fails, see the installation step above: No module named seaborn is fixed with python -m pip install seaborn.

Free alternatives and related plots

Option What it is (from the official documentation)
seaborn.violinplot() Axes-level violin plot with KDE, inner box, split and hue support.
seaborn.catplot(kind="violin") Figure-level interface that draws the same violin and supports facets.
Matplotlib Axes.violinplot(dataset, ...) Makes a violin plot for each column of a dataset or each vector in a sequence; returns a dict of the created components. showmeans and showmedians default to False, and showextrema defaults to True.
seaborn swarmplot() or stripplot() on top of a violin The tutorial calls it useful to combine these with a box plot or violin plot.

FAQ

How do I make a seaborn violin plot?

Call sns.violinplot(data=df, x="category", y="value") with a DataFrame, then display it with plt.show(). Add hue to compare a second grouping.

What is the difference between seaborn violinplot and a box plot?

A box plot shows quartiles and whiskers only. The violin plot adds a KDE outline, and the quartile and whisker values of the box plot are shown inside it by default (inner="box").

How do I show the individual data points in a violin plot?

Set inner="point" or inner="stick", or draw a swarmplot() or stripplot() on the same Axes with inner=None on the violin.

Why does my violin extend past the data range?

The default cut=2 extends the density two bandwidths past the extreme data points. Use cut=0 to limit it to the data range.

Why do I get a warning about scale or bw?

Those parameters were deprecated in 0.13.0. Use density_norm in place of scale, common_norm in place of scale_hue, and bw_method or bw_adjust in place of bw.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Seaborn Violin Plots: sns.violinplot Syntax, Parameters and Examples

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.