import matplotlib.pylab as plt
import numpy as np
# Create some example data
y = np.random.normal(5, size=1000)
# Usual histogram plot
fig = plt.figure()
ax1 = fig.add_subplot(121)
n, bins, patches = ax1.hist(y, bins=50) # output is two arrays
# Scatter plot
# Now we find the center of each bin from the bin edges
bins_mean = [0.5 * (bins[i] + bins[i+1]) for i in range(len(n))]
ax2 = fig.add_subplot(122)
ax2.scatter(bins_mean, n)
我想你要找的是:
本质上
plt.hist()
输出两个数组(正如Nordev指出的那样)。第一个是每个bin(n
)中的计数,第二个是bin的边缘。这是我能想到的最好的一个问题,没有更多的描述。对不起,如果我误解了。
相关问题 更多 >
编程相关推荐