image thumbnail

Violin Plot

버전 (9.07 KB) 작성자: Holger Hoffmann
Violin Plot based on kernel density estimation, using default ksdensity

다운로드 수: 12.1K

업데이트 날짜: 2015/11/3

라이선스 보기

This function creates simple violin plots by estimating the kernel density, using matlabs default ksdensity(). Given a matrix or table with m columns, you will get violins for each of the columns.
Key Features:
a) Specify plotting features as facecolor, edgecolor, etc.
b) Provide data with variable column length as cells if wanted, e.g. Y = [100x1 double] [10x1 double]
c) Plot Violins on the desired x-position


1) This function is not perfect. Please modify it as you like.

2) Please do consider the function by Jonas: "Violin Plots for plotting multiple distributions (distributionPlot.m)" which gets you the histograms as shape.

3) Please note: Kernel density is estimated with ksdensity which uses a gaussian kernel by default. Although the bandwidth is optimal according to the rule of thumb, it is however estimated separately for each violin. For publications, etc., please consider that you might need to use the same kernel bandwidths for all data-subsets in order to be able to really compare the distributions.

A beautiful example is given here:

인용 양식

Holger Hoffmann (2022). Violin Plot (, MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2013a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!