Reputation: 449
I am reviewing the matpoltlib and seaborn packages. I know this question is a little below the level of stack but no one can give me a solid answer about this error. I am using displot to make histograms and the notes are trying to show the difference between it displaying w/ count vs. density. Using the "iris" dataset w/in seaborn the first example is:
[IN]: sns.displot(iris["sepal_length"], kde=False)
[OUT]: histogram, no curve, count on the y-axis
The next example uses "norm_hist" and is supposed to change the counts to densities and I am getting an error I don't understand?
[IN]: sns.displot(iris["sepal_length"], norm_hist=True, kde=False)
[OUT]: Traceback (most recent call last):
File "C:\Users\cyrra\OneDrive\Documents\HDS 802 - Programming in Healthcare (Python & R)\Module 7 Python\M7P - MINE.py", line 79, in <module>
sns.displot(iris["sepal_length"], norm_hist=True, kde=False)
File "C:\Users\cyrra\anaconda3\lib\site-packages\seaborn\distributions.py", line 2227, in displot
p.plot_univariate_histogram(**hist_kws)
File "C:\Users\cyrra\anaconda3\lib\site-packages\seaborn\distributions.py", line 555, in plot_univariate_histogram
artists = plot_func(
File "C:\Users\cyrra\anaconda3\lib\site-packages\matplotlib\__init__.py", line 1438, in inner
return func(ax, *map(sanitize_sequence, args), **kwargs)
File "C:\Users\cyrra\anaconda3\lib\site-packages\matplotlib\axes\_axes.py", line 2488, in bar
r.update(kwargs)
File "C:\Users\cyrra\anaconda3\lib\site-packages\matplotlib\artist.py", line 996, in update
raise AttributeError(f"{type(self).__name__!r} object "
AttributeError: 'Rectangle' object has no property 'norm_hist'
Can someone explain this to me? I am looking through the documentation for seaborn and I can't seem to find these options. Were they deprecated? Unfortunately the material provided for my python class in my MS is from 2017 and they won't update it.
Thank you
Upvotes: 7
Views: 57300
Reputation: 29
You must use density insted of normed for errors as 'rectangle' object has no property 'normed'
Upvotes: 0
Reputation: 160
I had this same error and my solution was
changing ffn/core.py
(it was the first file in the error list, your file is different I see, but same principle norm something must be deprecated?)
from
ax = ser.hist(bins=bins, figsize=figsize, normed=True, **kwargs)
to
ax = ser.hist(bins=bins, figsize=figsize, density=True, **kwargs)
point being: changing the normed to density i.e. here norm_hist to density
Upvotes: 12
Reputation: 5745
According to the documentation, displot
indeed does not have this parameter.
your are confused with the deprecated distplot
function (here) that has it.
Upvotes: 4