Skip to content

AttributeError: can't set attribute #594

Closed

Description

@qianwu2

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

Activity

  1. molinav commented on Dec 25, 2023

    @molinav
    Member

    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.

  2. rcomer commented on Dec 30, 2023

    @rcomer
    Member

    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.

  3. molinav commented on Jan 6, 2024

    @molinav
    Member

    @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.

  4. molinav commented on Jan 7, 2024

    @molinav
    Member

    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.

  5. qianwu2 commented on Jan 7, 2024

    @qianwu2
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions