【源码】基于核密度估计的小提琴图表绘制

在这里插入图片描述
本函数使用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/

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值