当前位置:   article > 正文

【源码】基于核密度估计的小提琴图表绘制_kernel density estimation violin plot

kernel density estimation violin plot

在这里插入图片描述
本函数使用MATLAB自带的ksdensity()函数,通过估计核密度来创建简单的小提琴图表。

This function creates simple violin plots by estimating the kernel density, using matlabs default ksdensity().

给定一个矩阵或带有m列的表格,您将得到每列数据的小提琴图。

Given a matrix or table with m columns, you will get violins for each of the columns.

主要特点:

Key Features:

a) 设置facecolor, edgecolor等参数。

a) Specify plotting features as facecolor, edgecolor, etc.

b) 如果需要,提供可变列长度的数据作为单元格,例如Y = [100x1 double] [10x1 double]

b) Provide data with variable column length as cells if wanted, e.g. Y = [100x1 double] [10x1 double]

c) 在期望的x位置上绘制小提琴图。

c) Plot Violins on the desired x-position

注意:

Notes:

  1. 该函数并不完美,可以根据您的需要进行修改。

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

  3. Jonas撰写的函数:“用于绘制多个分布的小提琴图(distributionPlot.m)”,可以获得柱状直方图。

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

  5. 采用ksdensity实现核密度的估计,默认为高斯核函数。

  6. 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.

在以下网页可以找到一个不错的示例:http://www.matlabtips.com/beautiful-plots-in-matlab/

A beautiful example is given here:

http://www.matlabtips.com/beautiful-plots-in-matlab/

完整源码下载地址:

http://page2.dfpan.com/fs/8lc6j2021b294164da1/

更多精彩文章请关注微信号:在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/67152
推荐阅读
相关标签
  

闽ICP备14008679号