我的代码是:
import matplotlib as plt
sns.distplot(CMSU['Spending'], kde = False)
plt.xlabel("Spending", size=15)
plt.ylabel("Probablity", size=15)
plt.title("Distribution for the variable - Spending", size=18);
我得到一个错误:
AttributeError Traceback (most recent call last)
<ipython-input-32-1c6eb744a592> in <module>
1 sns.distplot(CMSU['Spending'], kde = False)
----> 2 plt.xlabel("Spending", size=15)
3 plt.ylabel("Probablity", size=15)
4 plt.title("Distribution for the variable - Spending", size=18);
AttributeError: module 'matplotlib' has no attribute 'xlabel'
有什么可能出错
你的
import
陈述是错误的。这些方法属于pyplot
。也就是说,您应该像这样导入它:我认为您需要执行
import matplotlib.pyplot as plt
而不仅仅是matplotlib as plt
,因为xlabel
和其他各种函数在matplotlib中不存在使用:
与
ylabel
和title
相同:相关问题 更多 >
编程相关推荐