【问题标题】:plot the histogram of a 1D array in Numpy在 Numpy 中绘制一维数组的直方图
【发布时间】:2013-11-24 04:46:11
【问题描述】:

我有一个 1D numpy 数组 h=[h1,h2,h3....hn] 我用这个为权重创建了 x=[1,2,3...n]

代码:

import numpy as np
x=np.arange(len(h))

我想画直方图,不知道怎么画? 谢谢。

这是我的数据:https://www.dropbox.com/s/xx02015pbr484es/Book2.xlsx 我想要这样的东西:

【问题讨论】:

标签: python numpy matplotlib plot scipy


【解决方案1】:

我推荐pandas,它还包装了maplotlib 的绘图函数,并允许您直接使用DataFrame 对象方法进行绘图:

import pandas

df = pandas.read_excel('Book2.xlsx', 'Sheet1')
df.plot()

【讨论】:

    猜你喜欢
    • 2015-10-14
    • 1970-01-01
    • 2020-09-25
    • 2014-06-12
    • 2013-09-21
    • 2016-05-18
    • 2021-07-17
    • 2022-12-18
    • 2021-10-13
    相关资源
    最近更新 更多