AttributeError:“GeoAxesSubplot”对象没有属性“_autoscaleXon”

问题描述 投票:0回答:2

我正在尝试运行使用 cartopy 的代码,但收到以下错误:

AttributeError:“GeoAxesSubplot”对象没有属性“_autoscaleXon”

我将 matplotlib 降级到以前的版本(3.5)并升级 cartopy 但我仍然遇到相同的错误。

有人知道如何解决吗?

python gis geospatial cartopy
2个回答
0
投票

我也从

cartopy
0.18 和
matplotlib
3.5.2 和
matplotlib-base
3.6.3 开始遇到这个问题,并收到有关自动缩放的错误。

我卸载了

cartopy
,然后尝试安装
cartopy
0.21,如下所示:

conda install cartopy
pip install cartopy==0.21
pip install cartopy

我不断收到构建错误,告诉我需要将 Microsoft C++ 升级到版本 14 或更高版本 (我有)。

最后我去了 [https://scitools.org.uk/cartopy/docs/latest/installing.html]

我首先按照他们关于依赖项的说明进行操作:

  1. pip install GEO(已安装 GEOS-0.2.3)
  2. pip install shapely(已满足要求)
  3. pip install pyshp(已经满意了)

然后我运行了这个安装:

conda install -c conda-forge cartopy

(已安装cartopy-0.21.1和shapely-2.0.1)

现在可以了。请注意,不确定我之前何时进行 conda install 为什么它无法构建,而这次却构建了。我不认为 conda-forge 是我的默认频道。


0
投票

有点晚了,但我也遇到了这个问题,并且在重新安装 Cartopy 或更改我的环境方面没有任何运气。不过,一个快速的解决方法是自行将属性添加到绘图轴中。它至少对我有用。我做了以下事情。

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

transform = ccrs.PlateCarree()

fig = plt.figure(figsize=(16,8))
ax = fig.add_subplot(1, 1, 1, projection=transform)

ax._autoscaleXon = False
ax._autoscaleYon = False

# Continue to make your plot below without error.

这显然并不理想,但它确实对我有用,现在我可以停止扰乱我的环境了。

© www.soinside.com 2019 - 2024. All rights reserved.