【问题标题】:Log of the Frequency in Histogram直方图中频率的对数
【发布时间】:2015-03-04 22:44:25
【问题描述】:

我使用matplotlib.pyplot.hist 绘制数组的直方图。当Log=True 时,y 轴将设置为对数刻度。我想要的是在 y 轴上绘制对数(频率)。如何实现?

【问题讨论】:

    标签: python histogram


    【解决方案1】:

    如果“频率”是指速率,即每秒某个值出现的次数,那么您可以将 weights 关键字参数添加到您的 pyplot.hist() 调用中,如文档中的 here 所示。

    您需要将weights 作为一个与您的数据大小相同的数组,以便您可以使用

    weights = numpy.ones_like(x.shape) / duration
    

    其中duration 是数据有效的总时间。

    【讨论】:

    • 频率是指(一个值出现的次数)/(值的总数)。我现在试一试。谢谢。
    猜你喜欢
    • 2015-10-11
    • 1970-01-01
    • 2019-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-03
    相关资源
    最近更新 更多