Reputation: 115
I try running the following code
import numpy as np
import matplotlib.pyplot as plt
x = np.random.randn(1000)
plt.hist(x, bins=50, density=True)
plt.show()
And I get the following error message:
AttributeError: Unknown property density
What's wrong?
Upvotes: 2
Views: 3212
Reputation: 89
What is the Python version and matplotlib version you are using?
Older versions of matplotlib (e.g. 1.3.1) don't have the density
parameter, but instead have the normed
parameter. This is probably why you are getting the AttributeError
.
To check the matplotlib version, you can simply do:
python -m pip list
Versions of matplotlib above 2.0 all have the density
parameter.
Upvotes: 4