'AxesSubplot' object has no attribute 'get_axis_bgcolor'
Asked Answered
C

2

2

I am trying to run Basemap examples from here and I am facing an error 'AxesSubplot' object has no attribute 'get_axis_bgcolor'. When I try first example from the site I should receive contours black, water blue and land coral, but in my case boundaries are black but both water and land are blue

I am using: -Python 3.5.5 -Matplotlib 2.2.2

Would appreciate any help.

Cappuccino answered 5/6, 2018 at 2:26 Comment(3)
Please be specific, there are several examples there. Which one did you use?Beebe
Which version of Basemap are you using? Which code is run to produce this error? Provide the full error traceback instead of the last line.Hobart
I had exactly the same issue and solved it - see answer below.Jarret
J
11

Basemap (even current latest version 1.0.7) is using deprecated Matplotlib command (see: matplotlib.org/api/_as_gen/…). This command ax.get_axis_bgcolor() needs to be replaced by ax.get_fc() in the file __init__.py found in the ...\lib\pythonX.X\site-packaged\mpl_toolkits\basemap directory.

There are instances in the following two functions drawmapboundary() and fillcontinents().

Save the edits, then re-start and run the python script.

Jarret answered 19/6, 2018 at 12:29 Comment(2)
ax.ishold() is another deprecated matplotlib function which baseplot uses (though this one doesn't break the script).Jarret
Worked great, also to use with Python3 all the print commands in the init.py must use parentheses .Quoit
L
2

Just replace set_axis_bgcolor with set_facecolor

Limpkin answered 24/5, 2022 at 9:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.