【问题标题】:Centering histogram bins and setting percentage range in Matlab在 Matlab 中居中直方图箱并设置百分比范围
【发布时间】:2013-10-18 11:31:20
【问题描述】:

我正在 Matlab 中进行数据分析,并将离散值 (1-15) 的频率绘制成 Matlab 的直方图。我想将垃圾箱居中,使第一个垃圾箱的中心值为 1,第二个垃圾箱的中心值为 2,等等。

我还想获得 Y 轴的百分比范围。任何快速的想法如何做到这一点?这是一张突出我的问题的图片:

【问题讨论】:

  • 看看hist(需要bin centershistc(需要bin edges)。
  • +1 谢谢你的帮助 :)

标签: matlab plot histogram


【解决方案1】:

首先将hist 与您预期的中心一起使用。然后使用barxlabel 以您想要的方式显示带有y 轴的直方图:

dat = randi(15,100,1);
centers = 1:15;
counts = hist(dat,centers);
pcts = 100 * counts / sum(counts);
bar(centers,counts)
ylabel('%')

【讨论】:

    猜你喜欢
    • 2015-05-15
    • 1970-01-01
    • 1970-01-01
    • 2014-01-30
    • 1970-01-01
    • 2016-02-10
    • 2020-05-03
    • 1970-01-01
    • 2021-12-09
    相关资源
    最近更新 更多