【发布时间】:2014-07-16 05:56:39
【问题描述】:
我正在尝试在特定范围内制作直方图,但 matplotlib.pyplot.hist() 函数不断将范围裁剪到包含条目的 bin 中。一个玩具例子:
import numpy as np
import matplotlib.pyplot as plt
x = np.random.uniform(-100,100,1000)
nbins = 100
xmin = -500
xmax = 500
fig = plt.figure();
ax = fig.add_subplot(1, 1, 1)
ax.hist(x, bins=nbins,range=[xmin,xmax])
plt.show()
给出一个范围为 [-100,100] 的图。为什么范围不是指定的 [-500,500]?
(我使用的是 Enthought Canopy 1.4,很抱歉,我没有足够高的代表来发布该情节的图像。)
【问题讨论】:
标签: python matplotlib range histogram