You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 12:23:09