调用sns.jointplot触发TypeError:位置参数传入数量不符合要求
解决sns.jointplot()的TypeError问题
错误原因
新版Seaborn的jointplot()已不再支持直接传入两个位置参数(旧版本允许sns.jointplot(data_col1, data_col2)这类写法),必须显式通过关键字参数指定x和y,否则会触发参数数量不匹配的TypeError。
修正后的代码
有两种可行的修正方式:
- 直接指定x、y参数为对应的数据列:
plt.figure(figsize=(15,10)) sns.jointplot(x=data.radius_mean, y=data.area_mean, kind="reg") plt.show()
- 结合
data参数,传入列名的字符串:
plt.figure(figsize=(15,10)) sns.jointplot(x="radius_mean", y="area_mean", data=data, kind="reg") plt.show()
内容的提问来源于stack exchange,提问作者Ngeteh
相关产品推荐
相关产品推荐

