sns.distplot問題, AttributeError: 'Rectangle' object has no property 'normed'
執行範例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
有在網路上找過問題,但找不到解答,想詢問是否哪裡有誤? 或者是否有其他寫法?
回答列表
-
2020/04/09 下午 05:41Jeffrey贊同數:0不贊同數:0留言數:1
請問一下, 有改過程式碼? 相關的套件都已經安裝了?
-
2020/04/09 下午 11:05張維元 (WeiYuan)贊同數:0不贊同數:0留言數:1
嗨,明敏
你可以把整段執行的程式碼,包含錯誤訊息一起貼上來嗎?這樣比較方便做回應。
如果這個回答對你有幫助請主動點選「有幫助」的按鈕,也可以追蹤我的GITHUB帳號。若還有問題的話,也歡迎繼續再追問或者把你理解的部分整理上來,我都會提供你 Review 和 Feedback 😃😃😃
-
2020/04/10 上午 00:28張維元 (WeiYuan)贊同數:0不贊同數:0留言數:1
嗨,明敏
我剛剛執行上是可以的,請問你的 Python 以及 sns 版本分別為何?
如果這個回答對你有幫助請主動點選「有幫助」的按鈕,也可以追蹤我的GITHUB帳號。若還有問題的話,也歡迎繼續再追問或者把你理解的部分整理上來,我都會提供你 Review 和 Feedback 😃😃😃
-
2020/04/12 上午 02:15張維元 (WeiYuan)贊同數:0不贊同數:0留言數:3
嗨,明敏
「下面是python及sns版本: Python 3.6.5 seaborn 0.8.1」
我的 seaborn 版本是 0.9.0,可以更新後試試看:)
如果這個回答對你有幫助請主動點選「有幫助」的按鈕,也可以追蹤我的GITHUB帳號。若還有問題的話,也歡迎繼續再追問或者把你理解的部分整理上來,我都會提供你 Review 和 Feedback 😃😃😃