首页 > 解决方案 > 获取 matplotlib.collections.PolyCollection 的轴

问题描述

我想获得 a 的轴matplotlib.collections.PolyCollection。如果 pc 是这样一个对象,运行下面的代码:

ax = pc.axes.get_xaxis()

虽然我的代码之前一直在工作,但我遇到了以下警告:

MatplotlibDeprecationWarning: get_axes 在 mpl 1.5 中已被弃用,请使用 axes 属性。移除日期尚未确定。

但是现在我在运行相同的程序时遇到了这个错误:

“PolyCollection”对象没有属性“get_axes”

get_axes 折旧后如何获得轴?

标签: pythonmatplotlibplotsubplot

解决方案


您提到的警告建议改用 axes 属性。查看文档,axes 是现有属性,而 get_axes 不是。它应该按预期返回 Axes 实例。


推荐阅读