`AttributeError: 'Axes' object has no attribute '_axes_class'` after update to matplotlib-base 3.7.0
Created by: fahlb
Problem description:
After updating from matplotlib-base-3.6.2
to matplotlib-base-3.7.0
, the following error occurs inside a previously working notebook:
------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[3], line 13base
11 ax.set_ylabel('Frequency [Hz]')
12 ax.grid(True, axis='y', which='both')
---> 13 ax.colorbar(cmap='viridis', label='Normalized energy')
14 plot.show()
File ~/.conda/envs/ASTRO/lib/python3.10/site-packages/gwpy/plot/axes.py:612, in Axes.colorbar(self, mappable, **kwargs)
610 if kwargs.get('fraction', 0.) == 0.:
611 kwargs.setdefault('use_axesgrid', True)
--> 612 mappable, kwargs = gcbar.process_colorbar_kwargs(
613 fig, mappable=mappable, ax=self, **kwargs)
614 if isinstance(fig, Plot):
615 # either we have created colorbar Axes using axesgrid1, or
616 # the user already gave use_axesgrid=False, so we forcefully
617 # disable axesgrid here in case fraction == 0., which causes
618 # gridspec colorbars to fail.
619 kwargs['use_axesgrid'] = False
File ~/.conda/envs/ASTRO/lib/python3.10/site-packages/gwpy/plot/colorbar.py:111, in process_colorbar_kwargs(figure, mappable, ax, cax, use_axesgrid, **kwargs)
109 kwargs.pop("fraction", None)
110 elif use_axesgrid: # use axesgrid to generate Axes
--> 111 cax, kwargs = make_axes_axesgrid(ax, **kwargs)
112 # else: let matplotlib generate the Axes using its own default
113
114 # pack kwargs
115 kwargs.update(ax=ax, cax=cax)
File ~/.conda/envs/ASTRO/lib/python3.10/site-packages/gwpy/plot/colorbar.py:163, in make_axes_axesgrid(ax, **kwargs)
161 if fraction:
162 return _make_axes_div(ax, fraction=fraction, **kwargs)
--> 163 return _make_axes_inset(ax, **kwargs)
164 finally:
165 ax.figure.sca(ax)
File ~/.conda/envs/ASTRO/lib/python3.10/site-packages/gwpy/plot/colorbar.py:182, in _make_axes_inset(ax, location, **kwargs)
177 from mpl_toolkits.axes_grid1.inset_locator import inset_axes
179 location = location.lower()
181 inset_kw = {
--> 182 'axes_class': _get_axes_class(ax),
183 'bbox_transform': ax.transAxes,
184 'borderpad': 0.,
185 }
187 # get orientation based on location
188 if location.lower() in ('left', 'right'):
File ~/.conda/envs/ASTRO/lib/python3.10/site-packages/gwpy/plot/colorbar.py:141, in _get_axes_class(ax)
139 def _get_axes_class(ax):
140 if isinstance(ax, SubplotBase):
--> 141 return ax._axes_class
142 return type(ax)
AttributeError: 'Axes' object has no attribute '_axes_class'
Problem analysis:
After some testing with fresh conda environments, I've narrowed the problem down to the most recent version of matplotlib-base-3.7.0
. In a clean install, there is only matplotlib-base-3.4.3
installed alongside GWpy. Up to matplotlib-base-3.6.3
there are no errors. After upgrading to matplotlib-base-3.7.0
, the error occurs.
I assume some change there is incompatible with GWpy and require some changes to adapt.
Note: Conda does not provide matplotlib-3.6.3
and I couldn't test it specifically but everything works with this version on my other machine!
Note: In matplotlib-3.7.0
I also get the following deprecation warning. I don't know if they might be related:
/tmp/ipykernel_99704/3175995638.py:10: MatplotlibDeprecationWarning: The get_cmap function was deprecated in Matplotlib 3.7 and will be removed two minor releases later. Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap(obj)`` instead.
Minimal code example:
Example taken from here: https://gwpy.github.io/docs/latest/examples/timeseries/qscan/
from gwpy.timeseries import TimeSeries
data = TimeSeries.fetch_open_data('H1', 1126259446, 1126259478)
qspecgram = data.q_transform(outseg=(1126259462.2, 1126259462.5))
plot = qspecgram.plot(figsize=[8, 4])
ax = plot.gca()
ax.set_xscale('seconds')
ax.set_yscale('log')
ax.set_ylim(20, 500)
ax.set_ylabel('Frequency [Hz]')
ax.grid(True, axis='y', which='both')
ax.colorbar(cmap='viridis', label='Normalized energy')
plot.show()
Installed packages producing error:
# packages in environment at /home/felix/.conda/envs/ASTRO:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
anyio 3.5.0 py310h06a4308_0
appdirs 1.4.4 pyhd3eb1b0_0
argon2-cffi 21.3.0 pyhd3eb1b0_0
argon2-cffi-bindings 21.2.0 py310h7f8727e_0
astropy 5.1 py310ha9d4c09_0
asttokens 2.0.5 pyhd3eb1b0_0
attrs 22.1.0 py310h06a4308_0
babel 2.11.0 py310h06a4308_0
backcall 0.2.0 pyhd3eb1b0_0
beautifulsoup4 4.11.1 py310h06a4308_0
blas 1.0 mkl
bleach 4.1.0 pyhd3eb1b0_0
brotli 1.0.9 h5eee18b_7
brotli-bin 1.0.9 h5eee18b_7
brotlipy 0.7.0 py310h7f8727e_1002
bzip2 1.0.8 h7b6447c_0
ca-certificates 2023.01.10 h06a4308_0
certifi 2022.12.7 py310h06a4308_0
cffi 1.15.1 py310h5eee18b_3
charset-normalizer 2.0.4 pyhd3eb1b0_0
comm 0.1.2 py310h06a4308_0
contourpy 1.0.5 py310hdb19cb5_0
cryptography 39.0.1 py310h9ce1e76_0
cycler 0.11.0 pyhd3eb1b0_0
debugpy 1.5.1 py310h295c915_0
decorator 5.1.1 pyhd3eb1b0_0
defusedxml 0.7.1 pyhd3eb1b0_0
dqsegdb2 1.1.3 pyhd8ed1ab_0 conda-forge
entrypoints 0.4 py310h06a4308_0
executing 0.8.3 pyhd3eb1b0_0
flit-core 3.6.0 pyhd3eb1b0_0
fonttools 4.25.0 pyhd3eb1b0_0
freetype 2.12.1 h4a9f257_0
giflib 5.2.1 h5eee18b_3
gwdatafind 1.1.3 pyhd8ed1ab_0 conda-forge
gwosc 0.6.1 pyhd8ed1ab_0 conda-forge
gwpy 3.0.2 pyhd8ed1ab_0 conda-forge
h5py 3.7.0 py310he06866b_0
hdf5 1.10.6 h3ffc7dd_1
icu 58.2 he6710b0_3
idna 3.4 py310h06a4308_0
igwn-auth-utils 0.4.0 pyhd8ed1ab_0 conda-forge
intel-openmp 2021.4.0 h06a4308_3561
ipykernel 6.19.2 py310h2f386ee_0
ipython 8.10.0 py310h06a4308_0
ipython_genutils 0.2.0 pyhd3eb1b0_1
jedi 0.18.1 py310h06a4308_1
jinja2 3.1.2 py310h06a4308_0
jpeg 9e h5eee18b_1
json5 0.9.6 pyhd3eb1b0_0
jsonschema 4.17.3 py310h06a4308_0
jupyter_client 7.4.9 py310h06a4308_0
jupyter_core 5.2.0 py310h06a4308_0
jupyter_server 1.23.4 py310h06a4308_0
jupyterlab 3.5.3 py310h06a4308_0
jupyterlab_pygments 0.1.2 py_0
jupyterlab_server 2.19.0 py310h06a4308_0
kiwisolver 1.4.4 py310h6a678d5_0
lcms2 2.12 h3be6417_0
ld_impl_linux-64 2.38 h1181459_1
lerc 3.0 h295c915_0
libbrotlicommon 1.0.9 h5eee18b_7
libbrotlidec 1.0.9 h5eee18b_7
libbrotlienc 1.0.9 h5eee18b_7
libdeflate 1.17 h5eee18b_0
libffi 3.4.2 h6a678d5_6
libgcc-ng 11.2.0 h1234567_1
libgfortran-ng 11.2.0 h00389a5_1
libgfortran5 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libpng 1.6.39 h5eee18b_0
libsodium 1.0.18 h7b6447c_0
libstdcxx-ng 11.2.0 h1234567_1
libtiff 4.5.0 h6a678d5_2
libuuid 1.41.5 h5eee18b_0
libwebp 1.2.4 h11a3e52_1
libwebp-base 1.2.4 h5eee18b_1
libxml2 2.9.14 h74e7548_0
libxslt 1.1.35 h4e12654_0
ligo-segments 1.4.0 py310h6acc77f_2 conda-forge
ligotimegps 2.0.1 py_0 conda-forge
lxml 4.9.1 py310h1edc446_0
lz4-c 1.9.4 h6a678d5_0
markupsafe 2.1.1 py310h7f8727e_0
matplotlib-base 3.7.0 py310h1128e8f_0
matplotlib-inline 0.1.6 py310h06a4308_0
mistune 0.8.4 py310h7f8727e_1000
mkl 2021.4.0 h06a4308_640
mkl-service 2.4.0 py310h7f8727e_0
mkl_fft 1.3.1 py310hd6ae3a3_0
mkl_random 1.2.2 py310h00e6091_0
munkres 1.1.4 py_0
nbclassic 0.5.2 py310h06a4308_0
nbclient 0.5.13 py310h06a4308_0
nbconvert 6.5.4 py310h06a4308_0
nbformat 5.7.0 py310h06a4308_0
ncurses 6.4 h6a678d5_0
nest-asyncio 1.5.6 py310h06a4308_0
notebook 6.5.2 py310h06a4308_0
notebook-shim 0.2.2 py310h06a4308_0
numpy 1.23.5 py310hd5efca6_0
numpy-base 1.23.5 py310h8e6c178_0
openssl 1.1.1t h7f8727e_0
packaging 22.0 py310h06a4308_0
pandocfilters 1.5.0 pyhd3eb1b0_0
parso 0.8.3 pyhd3eb1b0_0
pexpect 4.8.0 pyhd3eb1b0_3
pickleshare 0.7.5 pyhd3eb1b0_1003
pillow 9.4.0 py310h6a678d5_0
pip 22.3.1 py310h06a4308_0
platformdirs 2.5.2 py310h06a4308_0
pooch 1.4.0 pyhd3eb1b0_0
prometheus_client 0.14.1 py310h06a4308_0
prompt-toolkit 3.0.36 py310h06a4308_0
psutil 5.9.0 py310h5eee18b_0
ptyprocess 0.7.0 pyhd3eb1b0_2
pure_eval 0.2.2 pyhd3eb1b0_0
pycparser 2.21 pyhd3eb1b0_0
pyerfa 2.0.0 py310h7f8727e_0
pygments 2.11.2 pyhd3eb1b0_0
pyjwt 2.4.0 py310h06a4308_0
pyopenssl 23.0.0 py310h06a4308_0
pyparsing 3.0.9 py310h06a4308_0
pyrsistent 0.18.0 py310h7f8727e_0
pysocks 1.7.1 py310h06a4308_0
python 3.10.9 h7a1cb2a_1
python-dateutil 2.8.2 pyhd3eb1b0_0
python-fastjsonschema 2.16.2 py310h06a4308_0
python_abi 3.10 2_cp310 conda-forge
pytz 2022.7 py310h06a4308_0
pyyaml 6.0 py310h5eee18b_1
pyzmq 23.2.0 py310h6a678d5_0
readline 8.2 h5eee18b_0
requests 2.28.1 py310h06a4308_0
safe-netrc 1.0.0 py_0 conda-forge
scipy 1.10.0 py310hd5efca6_1
scitokens 1.7.4 pyhd8ed1ab_0 conda-forge
send2trash 1.8.0 pyhd3eb1b0_1
setuptools 65.6.3 py310h06a4308_0
six 1.16.0 pyhd3eb1b0_1
sniffio 1.2.0 py310h06a4308_1
soupsieve 2.3.2.post1 py310h06a4308_0
sqlite 3.40.1 h5082296_0
stack_data 0.2.0 pyhd3eb1b0_0
terminado 0.17.1 py310h06a4308_0
tinycss2 1.2.1 py310h06a4308_0
tk 8.6.12 h1ccaba5_0
tomli 2.0.1 py310h06a4308_0
tornado 6.2 py310h5eee18b_0
tqdm 4.64.1 py310h06a4308_0
traitlets 5.7.1 py310h06a4308_0
typing-extensions 4.4.0 py310h06a4308_0
typing_extensions 4.4.0 py310h06a4308_0
tzdata 2022g h04d1e81_0
urllib3 1.26.14 py310h06a4308_0
wcwidth 0.2.5 pyhd3eb1b0_0
webencodings 0.5.1 py310h06a4308_1
websocket-client 0.58.0 py310h06a4308_4
wheel 0.38.4 py310h06a4308_0
xz 5.2.10 h5eee18b_1
yaml 0.2.5 h7b6447c_0
zeromq 4.3.4 h2531618_0
zlib 1.2.13 h5eee18b_0
zstd 1.5.2 ha4553b6_0
matplotlib-base-3.7.0
-> matplotlib-base-3.6.2
):
Installed packages without error (# packages in environment at /home/felix/.conda/envs/ASTRO:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
anyio 3.5.0 py310h06a4308_0
appdirs 1.4.4 pyhd3eb1b0_0
argon2-cffi 21.3.0 pyhd3eb1b0_0
argon2-cffi-bindings 21.2.0 py310h7f8727e_0
astropy 5.1 py310ha9d4c09_0
asttokens 2.0.5 pyhd3eb1b0_0
attrs 22.1.0 py310h06a4308_0
babel 2.11.0 py310h06a4308_0
backcall 0.2.0 pyhd3eb1b0_0
beautifulsoup4 4.11.1 py310h06a4308_0
blas 1.0 mkl
bleach 4.1.0 pyhd3eb1b0_0
brotli 1.0.9 h5eee18b_7
brotli-bin 1.0.9 h5eee18b_7
brotlipy 0.7.0 py310h7f8727e_1002
bzip2 1.0.8 h7b6447c_0
ca-certificates 2023.01.10 h06a4308_0
certifi 2022.12.7 py310h06a4308_0
cffi 1.15.1 py310h5eee18b_3
charset-normalizer 2.0.4 pyhd3eb1b0_0
comm 0.1.2 py310h06a4308_0
contourpy 1.0.5 py310hdb19cb5_0
cryptography 39.0.1 py310h9ce1e76_0
cycler 0.11.0 pyhd3eb1b0_0
debugpy 1.5.1 py310h295c915_0
decorator 5.1.1 pyhd3eb1b0_0
defusedxml 0.7.1 pyhd3eb1b0_0
dqsegdb2 1.1.3 pyhd8ed1ab_0 conda-forge
entrypoints 0.4 py310h06a4308_0
executing 0.8.3 pyhd3eb1b0_0
flit-core 3.6.0 pyhd3eb1b0_0
fonttools 4.25.0 pyhd3eb1b0_0
freetype 2.12.1 h4a9f257_0
giflib 5.2.1 h5eee18b_3
gwdatafind 1.1.3 pyhd8ed1ab_0 conda-forge
gwosc 0.6.1 pyhd8ed1ab_0 conda-forge
gwpy 3.0.2 pyhd8ed1ab_0 conda-forge
h5py 3.7.0 py310he06866b_0
hdf5 1.10.6 h3ffc7dd_1
icu 58.2 he6710b0_3
idna 3.4 py310h06a4308_0
igwn-auth-utils 0.4.0 pyhd8ed1ab_0 conda-forge
intel-openmp 2021.4.0 h06a4308_3561
ipykernel 6.19.2 py310h2f386ee_0
ipython 8.10.0 py310h06a4308_0
ipython_genutils 0.2.0 pyhd3eb1b0_1
jedi 0.18.1 py310h06a4308_1
jinja2 3.1.2 py310h06a4308_0
jpeg 9e h5eee18b_1
json5 0.9.6 pyhd3eb1b0_0
jsonschema 4.17.3 py310h06a4308_0
jupyter_client 7.4.9 py310h06a4308_0
jupyter_core 5.2.0 py310h06a4308_0
jupyter_server 1.23.4 py310h06a4308_0
jupyterlab 3.5.3 py310h06a4308_0
jupyterlab_pygments 0.1.2 py_0
jupyterlab_server 2.19.0 py310h06a4308_0
kiwisolver 1.4.4 py310h6a678d5_0
lcms2 2.12 h3be6417_0
ld_impl_linux-64 2.38 h1181459_1
lerc 3.0 h295c915_0
libbrotlicommon 1.0.9 h5eee18b_7
libbrotlidec 1.0.9 h5eee18b_7
libbrotlienc 1.0.9 h5eee18b_7
libdeflate 1.17 h5eee18b_0
libffi 3.4.2 h6a678d5_6
libgcc-ng 11.2.0 h1234567_1
libgfortran-ng 11.2.0 h00389a5_1
libgfortran5 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libpng 1.6.39 h5eee18b_0
libsodium 1.0.18 h7b6447c_0
libstdcxx-ng 11.2.0 h1234567_1
libtiff 4.5.0 h6a678d5_2
libuuid 1.41.5 h5eee18b_0
libwebp 1.2.4 h11a3e52_1
libwebp-base 1.2.4 h5eee18b_1
libxml2 2.9.14 h74e7548_0
libxslt 1.1.35 h4e12654_0
ligo-segments 1.4.0 py310h6acc77f_2 conda-forge
ligotimegps 2.0.1 py_0 conda-forge
lxml 4.9.1 py310h1edc446_0
lz4-c 1.9.4 h6a678d5_0
markupsafe 2.1.1 py310h7f8727e_0
matplotlib-base 3.6.2 py310h945d387_0
matplotlib-inline 0.1.6 py310h06a4308_0
mistune 0.8.4 py310h7f8727e_1000
mkl 2021.4.0 h06a4308_640
mkl-service 2.4.0 py310h7f8727e_0
mkl_fft 1.3.1 py310hd6ae3a3_0
mkl_random 1.2.2 py310h00e6091_0
munkres 1.1.4 py_0
nbclassic 0.5.2 py310h06a4308_0
nbclient 0.5.13 py310h06a4308_0
nbconvert 6.5.4 py310h06a4308_0
nbformat 5.7.0 py310h06a4308_0
ncurses 6.4 h6a678d5_0
nest-asyncio 1.5.6 py310h06a4308_0
notebook 6.5.2 py310h06a4308_0
notebook-shim 0.2.2 py310h06a4308_0
numpy 1.23.5 py310hd5efca6_0
numpy-base 1.23.5 py310h8e6c178_0
openssl 1.1.1t h7f8727e_0
packaging 22.0 py310h06a4308_0
pandocfilters 1.5.0 pyhd3eb1b0_0
parso 0.8.3 pyhd3eb1b0_0
pexpect 4.8.0 pyhd3eb1b0_3
pickleshare 0.7.5 pyhd3eb1b0_1003
pillow 9.4.0 py310h6a678d5_0
pip 22.3.1 py310h06a4308_0
platformdirs 2.5.2 py310h06a4308_0
pooch 1.4.0 pyhd3eb1b0_0
prometheus_client 0.14.1 py310h06a4308_0
prompt-toolkit 3.0.36 py310h06a4308_0
psutil 5.9.0 py310h5eee18b_0
ptyprocess 0.7.0 pyhd3eb1b0_2
pure_eval 0.2.2 pyhd3eb1b0_0
pycparser 2.21 pyhd3eb1b0_0
pyerfa 2.0.0 py310h7f8727e_0
pygments 2.11.2 pyhd3eb1b0_0
pyjwt 2.4.0 py310h06a4308_0
pyopenssl 23.0.0 py310h06a4308_0
pyparsing 3.0.9 py310h06a4308_0
pyrsistent 0.18.0 py310h7f8727e_0
pysocks 1.7.1 py310h06a4308_0
python 3.10.9 h7a1cb2a_1
python-dateutil 2.8.2 pyhd3eb1b0_0
python-fastjsonschema 2.16.2 py310h06a4308_0
python_abi 3.10 2_cp310 conda-forge
pytz 2022.7 py310h06a4308_0
pyyaml 6.0 py310h5eee18b_1
pyzmq 23.2.0 py310h6a678d5_0
readline 8.2 h5eee18b_0
requests 2.28.1 py310h06a4308_0
safe-netrc 1.0.0 py_0 conda-forge
scipy 1.10.0 py310hd5efca6_1
scitokens 1.7.4 pyhd8ed1ab_0 conda-forge
send2trash 1.8.0 pyhd3eb1b0_1
setuptools 65.6.3 py310h06a4308_0
six 1.16.0 pyhd3eb1b0_1
sniffio 1.2.0 py310h06a4308_1
soupsieve 2.3.2.post1 py310h06a4308_0
sqlite 3.40.1 h5082296_0
stack_data 0.2.0 pyhd3eb1b0_0
terminado 0.17.1 py310h06a4308_0
tinycss2 1.2.1 py310h06a4308_0
tk 8.6.12 h1ccaba5_0
tomli 2.0.1 py310h06a4308_0
tornado 6.2 py310h5eee18b_0
tqdm 4.64.1 py310h06a4308_0
traitlets 5.7.1 py310h06a4308_0
typing-extensions 4.4.0 py310h06a4308_0
typing_extensions 4.4.0 py310h06a4308_0
tzdata 2022g h04d1e81_0
urllib3 1.26.14 py310h06a4308_0
wcwidth 0.2.5 pyhd3eb1b0_0
webencodings 0.5.1 py310h06a4308_1
websocket-client 0.58.0 py310h06a4308_4
wheel 0.38.4 py310h06a4308_0
xz 5.2.10 h5eee18b_1
yaml 0.2.5 h7b6447c_0
zeromq 4.3.4 h2531618_0
zlib 1.2.13 h5eee18b_0
zstd 1.5.2 ha4553b6_0