使用Seaborn的factorplot函数报错:module 'seaborn' has no attribute 'factorplot'
解决Seaborn中
factorplot不存在的AttributeError问题 问题原因
Seaborn从0.9.0版本开始移除了factorplot()函数,它被更通用的catplot()函数取代,原factorplot的功能可通过catplot()指定对应kind参数实现。
修复代码
原报错代码:
sns.factorplot(x='size',y='tip',data=var) plt.show()
替换为等价代码:
# 原factorplot默认绘制点图,对应kind='point' sns.catplot(x='size', y='tip', data=var, kind='point') plt.show()
补充说明
- 若需绘制其他类型分类图,修改
kind参数即可:kind='box':箱线图kind='bar':条形图kind='violin':小提琴图
- 查看当前Seaborn版本的命令:
import seaborn as sns print(sns.__version__)
内容的提问来源于stack exchange,提问作者Titanium Gopal
相关产品推荐
相关产品推荐

