Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'GeoAxesSubplot' object has no attribute '_autoscaleXon' #2086

Closed
AlxLhrNc opened this issue Sep 23, 2022 · 11 comments
Closed

Comments

@AlxLhrNc
Copy link

Description

While trying to make a map, this triggered an error and wont produce any output.

Code to reproduce

import xarray as xr, numpy as np, matpyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature

def map_raster(data_nc, vmin=None, vmax=None,
               legend = '',
               cmap = 'viridis'):

        if vmin==None:
            vmin = np.nanmin(data_nc)
        if vmax==None:
            vmax = np.nanmax(data_nc)

        fig, mppng = plt.subplots(subplot_kw=dict(projection=proj))

        mppng.set_extent([min(ur_lon_mp, ll_lon_mp), max(ur_lon_mp, ll_lon_mp),
                          min(ll_lat_mp, ur_lat_mp), max(ll_lat_mp, ur_lat_mp)],
                         crs = proj
                         )

        lnd = cfeature.GSHHSFeature(scale='full')
        mppng.add_feature(lnd, facecolor = 'darkgray',
                          edgecolor = 'black', linewidth = .5,
                          zorder = 2)

        var_raster = mppng.pcolormesh(data_nc.lon, data_nc.lat,
                                      data_nc.squeeze(), cmap=cmap,
                                      vmin=vmin, vmax=vmax,
                                      transform=ccrs.PlateCarree())

        plt.close()
        plt.close()

        return fig
var = xr.open_dataset('file.nc')
map_raster(var)

Traceback

Traceback (most recent call last):

  File ~\Scripts\Python\training\training_cartopy.py:220
    map_raster(chla)

  File ~\Scripts\Python\training\training_cartopy.py:193 in map_raster
    var_raster = mppng.pcolormesh(data_nc.lon, data_nc.lat,

  File ~\Installed_Programs\Anaconda3\envs\prj\lib\site-packages\cartopy\mpl\geoaxes.py:318 in wrapper
    return func(self, *args, **kwargs)

  File ~\Installed_Programs\Anaconda3\envs\prj\lib\site-packages\cartopy\mpl\geoaxes.py:1804 in pcolormesh
    self.autoscale_view()

  File ~\Installed_Programs\Anaconda3\envs\prj\lib\site-packages\cartopy\mpl\geoaxes.py:946 in autoscale_view
    if scalex and self._autoscaleXon:

AttributeError: 'GeoAxesSubplot' object has no attribute '_autoscaleXon'
Full environment definition

Operating system

Windows 10

Cartopy version

cartopy 0.20.2

conda list

 (prj) C:\Users\AlxndrLhr>conda list cartopy
# packages in environment at C:\Users\AlxndrLhr\Installed_Programs\Anaconda3\envs\prj:
#
# Name                    Version                   Build  Channel
cartopy                   0.20.2           py39h07f1d72_4    conda-forge
matplotlib                3.6.0            py39hcbf5309_0    conda-forge
numpy                     1.23.3           py39h9061af7_0    conda-forge
xarray                    2022.6.0           pyhd8ed1ab_1    conda-forge

pip list

@dopplershift
Copy link
Contributor

What version of CartoPy do you have installed? This is triggered by matplotlib 3.6, and was fixed by the CartoPy 0.21 release.

@AlxLhrNc
Copy link
Author

I have 0.20.2 (see above in full environment def). I tried to update using conda update cartopy and conda update matplotlib as I've found the issue can come from that, to no avail. Honestly don't know what to do

@dopplershift
Copy link
Contributor

Ah, missed that environment. Try:
conda install cartopy=0.21

@AlxLhrNc
Copy link
Author

Tried it, turns out gdal create conflicts with cartopy 0.21 so i'll reinstall everything properly except gdal and get back to you

@akrherz
Copy link
Contributor

akrherz commented Sep 23, 2022

@AlxndrLhr just downgrade matplotlib to 3.5.2 and then you don't need the newer cartopy and the GDAL stack dependency issues currently within conda-forge.

@AlxLhrNc
Copy link
Author

Thanks @akrherz, the downgrading did the trick. Hope you all have a good day.

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Oct 7, 2022
Will do bump now.

Bug: SciTools/cartopy#2086
Signed-off-by: Sam James <sam@gentoo.org>
@xcmonline
Copy link

xcmonline commented Oct 17, 2022

Ah, missed that environment. Try: conda install cartopy=0.21

pip install --upgrade cartopy
hit: “geos_c.h”: No such file or directory

cartopy version 0.21.0
os windows 10

rasmunk added a commit to ucphhpc/nbi-jupyter-docker-stacks that referenced this issue Nov 23, 2022
jodemaey added a commit to EUPP-benchmark/climetlab-eumetnet-postprocessing-benchmark that referenced this issue Dec 21, 2022
@vijaykumarsagar
Copy link

vijaykumarsagar commented Jan 25, 2023

Ah, missed that environment. Try: conda install cartopy=0.21

pip install --upgrade cartopy hit: “geos_c.h”: No such file or directory

cartopy version 0.21.0 os windows 10

Thank you. "pip install --upgrade cartopy" has solved my problem.

trippsanders added a commit to trippsanders/lotw-qso-analyzer that referenced this issue Feb 16, 2023
@huangsiyr
Copy link

Tried it, turns out gdal create conflicts with cartopy 0.21 so i'll reinstall everything properly except gdal and get back to you

hello, can you show me how to downscaling matplotlib3.6 to matplotlib 3.5 with cartopy 0.19?

@rmDL4SON
Copy link

matplotlib 3.4.2
Cartopy 0.21.1

same issue suing above versions.

@QuLogic
Copy link
Member

QuLogic commented May 2, 2023

Then you are not truly using 0.21.1 (wrong environment?) because the string _autoscaleXon does not exist anywhere in that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants