pandas.scatter_matrix 返回错误:rowNum 属性在 Matplotlib 3.2 中已弃用,将在两个次要版本后删除

Posted

技术标签:

【中文标题】pandas.scatter_matrix 返回错误:rowNum 属性在 Matplotlib 3.2 中已弃用,将在两个次要版本后删除【英文标题】:pandas.scatter_matrix is returning the error: The rowNum attribute was deprecated in Matplotlib 3.2 and will be removed two minor releases later 【发布时间】:2020-06-19 14:39:59 【问题描述】:

我正在尝试使用 pandas.plotting 和 scatter_matrix 函数绘制特征配对图 但我收到以下错误,我无法理解其含义或我应该如何解决它:

from matplotlib import cm
        from pandas.plotting import scatter_matrix as sm
        import matplotlib.pyplot as plt
        `enter code here`import pandas as pd

    cmap = cm.get_cmap('gnuplot')
    scatter = sm(X_train, c=y_train, marker="o", s=40, hist_kwds= 'bins': 15, figsize=(12, 12), cmap=cmap)
/usr/local/lib/python3.7/site-packages/pandas/plotting/_matplotlib/tools.py:304: MatplotlibDeprecationWarning: 
The rowNum attribute was deprecated in Matplotlib 3.2 and will be removed two minor releases later. Use ax.get_subplotspec().rowspan.start instead.
  if not layout[ax.rowNum + 1, ax.colNum]:
/usr/local/lib/python3.7/site-packages/pandas/plotting/_matplotlib/tools.py:304: MatplotlibDeprecationWarning: 
The colNum attribute was deprecated in Matplotlib 3.2 and will be removed two minor releases later. Use ax.get_subplotspec().colspan.start instead.
  if not layout[ax.rowNum + 1, ax.colNum]

【问题讨论】:

这不是错误,而是警告。你可以忽略它。 你可以“暂时”忽略它,但在某些时候 pandas 需要更新它们的绘图功能,因为在 MPL 3.2 中这将停止工作。 【参考方案1】:

我也有同样的问题,而且确实是 pandas 的问题。 此问题已得到确认并已修复 - 只需获取最新版本的 Pandas 即可解决问题。

【讨论】:

【参考方案2】:

这似乎与熊猫内部绘图功能有关。我遇到了同样的错误,但是当我从 df['col'].plot() 更改为 plt.plot(df['col'] 时,错误消失了。

【讨论】:

以上是关于pandas.scatter_matrix 返回错误:rowNum 属性在 Matplotlib 3.2 中已弃用,将在两个次要版本后删除的主要内容,如果未能解决你的问题,请参考以下文章

Pandas scatter_matrix 中的类标签

如何修复 Pandas Scatter_matrix 中过长的轴标签?

EditContext OnFieldChanged 报错返回类型

根据报错信息返回判断系统容器系统

MFC中的SQL查询语句返回空就报错怎么办?

返回'无法从重复轴重新索引'…我在做什么错?