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

Seaborn pairplot触发Matplotlib弃用警告,求替代实现方案

解决Seaborn pairplot的Matplotlib弃用警告问题

复现代码

import pandas as pd
import seaborn as sns

df = pd.DataFrame(
         [
             [28, 72, 12],
             [28, 17, 25],
             [54, 15, 45],
             [30, 57, 28]
         ],
         columns = ["x", "y", "z"]
    )
cols = list(df.columns)
sns.pairplot(df)

运行后出现的警告

C:\Users\thaly\anaconda3\lib\site-packages\seaborn\axisgrid.py:1444:
MatplotlibDeprecationWarning: The join function was deprecated in Matplotlib 3.6
and will be removed two minor releases later.
group.join(ax, diag_axes[0])

解决方案

这个警告是Seaborn旧版本与Matplotlib 3.6+版本的API兼容问题导致的,不需要替换sns.pairplot(df),直接升级Seaborn到修复该问题的版本即可:

  • 使用pip升级:
pip install --upgrade seaborn
  • 若使用conda环境:
conda update seaborn

Seaborn 0.12.2及以上版本已经修复了这个内部调用的弃用问题,升级后再运行代码就不会出现该警告了。

内容的提问来源于stack exchange,提问作者Andrew

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 04:45:40