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: can't set attribute #594

Closed
qianwu2 opened this issue Nov 13, 2023 · 5 comments
Closed

AttributeError: can't set attribute #594

qianwu2 opened this issue Nov 13, 2023 · 5 comments

Comments

@qianwu2
Copy link

qianwu2 commented Nov 13, 2023

Hi,
I am running basemap version 1.3.4
Matplotlib 3.8
CentOS 7.8
Using conda.
Python 3.10.2
I got this error.

cs = m.contourf(x,y,pot,levels=clevs, alpha=1,cmap=plt.cm.RdBu_r)
Traceback (most recent call last):
File "/glade/u/home/qwu/gtrSep20/tiegcmnmf22020duskmewmeridicon092420200506sep2120202324paperafreviewmgladepy310.py", line 500, in
cs = m.contourf(x,y,pot,levels=clevs, alpha=1,cmap=plt.cm.RdBu_r)
File "/glade/work/qwu/conda-envs/qwu-env0/lib/python3.10/site-packages/mpl_toolkits/basemap/init.py", line 548, in with_transform
return plotfunc(self,x,y,data,*args,**kwargs)
File "/glade/work/qwu/conda-envs/qwu-env0/lib/python3.10/site-packages/mpl_toolkits/basemap/init.py", line 3704, in contourf
CS.collections,c = self._cliplimb(ax,CS.collections)
File "/glade/work/qwu/conda-envs/qwu-env0/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 164, in set
return super().set(instance, value)
AttributeError: can't set attribute

@molinav
Copy link
Member

molinav commented Dec 25, 2023

Hi, @qianwu2! Right now, the requirements file defines matplotlib >= 1.5, < 3.8; python_version >= "3.5", so matplotlib 3.8 falls outside the version range that is being tested.

In any case, I thank you for providing this feedback, because soon I will need to increase the upper pin for matplotlib to 3.9. I have not done it yet because I know that matplotlib 3.8 is bringing some changes that will break with basemap right now, so it is not only a matter of updating the requirements file.

@rcomer
Copy link
Member

rcomer commented Dec 30, 2023

I just tried the first (contour) and last (nightshade) examples from the docs with Matplotlib v3.8. The same line in those methods,

CS.collections,c = self._cliplimb(ax,CS.collections)

falls over for me with AttributeError: property of 'QuadContourSet' object has no setter consistent with this stackoverflow question. Since the ContourSet is now itself a collection, I suspect you just need to pass CS itself to your _cliplimb method.

@molinav
Copy link
Member

molinav commented Jan 6, 2024

@rcomer Thanks a lot for pointing to the specific issue. I will try to address it as soon as possible, because the basemap release 1.4.0 should arrive soon, and updating the matplotlib pin to <3.9 is a must in my todo list for 1.4.0.

molinav added a commit that referenced this issue Jan 7, 2024
@molinav
Copy link
Member

molinav commented Jan 7, 2024

The fix proposed by @rcomer has been added to all the affected methods (contour, contourf and nightshade), and I have also added some simple tests to the test suite to ensure that now it is working.

Thanks for your help! I will close the issue now, you will be able to use matplotlib 3.8.x with the basemap release 1.4.0, which should take place in one or two days at maximum.

@molinav molinav closed this as completed Jan 7, 2024
@qianwu2
Copy link
Author

qianwu2 commented Jan 7, 2024 via email

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

3 participants