pyicon_plotting.py: AttributeError: 'QuadContourSet' object has no attribute 'collections' for matplotlib version > 3.8
Hi,
I was trying to use pyicon with the modules that are mentioned in the same wiki as the anaconda workaround description referenced in the internal documentation i.e. this module list.
Using these newer modules produced an error:
Tbias: surface
Traceback (most recent call last):
File "pyicon_src/pyicon/quickplots/qp_driver.py", line 1671, in <module>
pyic.vplot_base(IcD, IaV, cmap='RdBu_r',
File "pyicon_src/pyicon/pyicon_plotting.py", line 340, in vplot_base
hm = shade(x, z, IaV.data, ax=ax, cax=cax,
File "pyicon_src/pyicon/pyicon_plotting.py", line 650, in shade
for cl in hm.collections:
AttributeError: 'QuadContourSet' object has no attribute 'collections'
A quick check online told me that the collections attribute was removed in version 3.8.
I've solved the error by adding some try-except AttributeError blocks to replace the loop over all elements of the collection with the set function of the object itself e.g. in line 650 of pyicon_plotting.py. (The try-except block is mostly to stay backwards compatible just replacing the loops would solve the issue for the newer versions as well.)
I don't have a user role that is allowed to start a merge request here. I could put my fix in one if that would help. Either way I wanted to document this here in case someone else runs into the error or I forget what I did to fix it.
Best, Lukas