logo
Loading...

sns.distplot問題, AttributeError: 'Rectangle' object has no property 'normed' - Cupoy

執行範例Day_023_Reduce_Skewness時,In[3]發生錯誤In[3]# 顯示 Lo...

顯示

sns.distplot問題, AttributeError: 'Rectangle' object has no property 'normed'

2020/04/09 06:09 AM
機器學習新手論壇
明敏
觀看數:0
回答數:4
收藏數:0
顯示

執行範例Day_023_Reduce_Skewness時,In[3]發生錯誤


In[3]

# 顯示 LotArea 的散佈圖

import seaborn as sns

import matplotlib.pyplot as plt

sns.distplot(df['LotArea'][:train_num])

plt.show()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-11-308560fdc636> in <module>()
     2 import seaborn as sns
     3 import matplotlib.pyplot as plt
----> 4 sns.distplot(df['LotArea'][:train_num])
     5 plt.show()

C:\ProgramData\Anaconda3\lib\site-packages\seaborn\distributions.py in distplot(a, bins, hist, kde, rug, fit, hist_kws, kde_kws, rug_kws, fit_kws, color, vertical, norm_hist, axlabel, label, ax)
   216         hist_color = hist_kws.pop("color", color)
   217         ax.hist(a, bins, orientation=orientation,
--> 218                 color=hist_color, **hist_kws)
   219         if hist_color != color:
   220             hist_kws["color"] = hist_color

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, data, *args, **kwargs)
  1563     def inner(ax, *args, data=None, **kwargs):
  1564         if data is None:
-> 1565             return func(ax, *map(sanitize_sequence, args), **kwargs)
  1566
  1567         bound = new_sig.bind(ax, *args, **kwargs)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in hist(self, x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)
  6806             if patch:
  6807                 p = patch[0]
-> 6808                 p.update(kwargs)
  6809                 if lbl is not None:
  6810                     p.set_label(lbl)

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py in update(self, props)
  1004
  1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
  1007
  1008         if len(ret):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py in <listcomp>(.0)
  1004
  1005         with cbook._setattr_cm(self, eventson=False):
-> 1006             ret = [_update_property(self, k, v) for k, v in props.items()]
  1007
  1008         if len(ret):

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\artist.py in _update_property(self, k, v)
  1000                 if not callable(func):
  1001                     raise AttributeError('{!r} object has no property {!r}'
-> 1002                                          .format(type(self).__name__, k))
  1003                 return func(v)
  1004

AttributeError: 'Rectangle' object has no property 'normed'



有產出圖(如下圖),但不是hist+kde plot

有在網路上找過問題,但找不到解答,想詢問是否哪裡有誤? 或者是否有其他寫法?