【发布时间】:2017-12-10 23:06:58
【问题描述】:
有没有办法在不绘制图表的情况下获得直方图“x”和“y”中的值**?我在我的代码中多次(在每个循环中)使用下面的函数,我注意到我的代码在每个循环中变得越来越慢。
** 我不确定它在内部的作用是否是绘图,但我知道我的代码中的缓慢与函数“plt.hist”有关,尽管使用了 plt.close()。谢谢。
# a is a list
def function_hist(a, ini, final):
# 12 bins
bins = np.linspace(ini, final, 13)
weightsa = np.ones_like(a)/float(len(a))
y, x, _ = plt.hist(a, bins, weights = weightsa)
plt.close()
【问题讨论】: