Violin Plot

版本 1.7.0.0 (9.1 KB) 作者: Holger Hoffmann
Violin Plot based on kernel density estimation, using default ksdensity
20.6K 次下载
更新时间 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

Notes:

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:
http://www.matlabtips.com/beautiful-plots-in-matlab/

引用格式

Holger Hoffmann (2024). Violin Plot (https://www.mathworks.com/matlabcentral/fileexchange/45134-violin-plot), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Exploration and Visualization 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.7.0.0

title changed
Documentation improved
title changed
Description updated

1.6.0.0

When providing x, axis was set incorrectly previously. This is fixed now.

1.5.0.0

- changed varargin list to parameter-value combination list
- plot violins on specific x-axis position possible now

1.4.0.0

- removed unnecessary text display

1.1.0.0

removed: set(gcf,'Color','w','Position',[2000 100 800 600])

1.0.0.0