AttributeError: Unknown property density

2019-06-27 17:27发布

问题:

I am trying to get a hold of SciPy, but I am stuck with Unknown property density error, even though I copied the whole code from official SciPy documentation.

This part worked fine:

x = np.linspace(norm.ppf(0.01), norm.ppf(0.99), 100)
ax.plot(x, norm.pdf(x), 'r-', lw=5, alpha=0.6, label='norm pdf')

rv = norm()
ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')

r = norm.rvs(size=1000)

But the following part gives me the AttributeError: Unknown property density:

ax.hist(r, density=True, histtype='stepfilled', alpha=0.2)
ax.legend(loc='best', frameon=False)
plt.show()