AttributeError: Unknown property density

DRPR picture DRPR · Jul 16, 2018 · Viewed 8.9k times · Source

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()

Answer

ali picture ali · Feb 12, 2020

I had a similar problem. I changed the python version from 2.7 to 3.6 and the problem solved.