0

I am relatively new to programming.

I'm trying to run the following:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np

my_map = Basemap(projection = 'ortho', lat_0=50, lon_0=-100,
                resolution = 'l', area_thresh=1000.0)

my_map.drawcoastlines()
my_map.drawcountries()
my_map.fillcontinents(color='red')

plt.show()

However, I get "AttributeError: 'AxesSubplot' object has no attribute 'get_axis_bgcolor'"

I'm using python 3.6, matplotlib 2.2.0, basemap 1.0.7. They were downloaded using Anaconda.

OS - Mac 10.12.4

How do I get rid of this error?

4 Answers 4

2

The matplotlib deprecated the get_axis_bgcolor. You'll need to update basemap to version 1.1.0 to fix this error. It's installable via conda-forge, via:

conda install -c conda-forge basemap

In case you'll get error like, "Unable to open boundary dataset file. Only the 'crude' and 'low', resolution datasets are installed by default." Install, the additional files via:

conda install -c conda-forge basemap-data-hires
Sign up to request clarification or add additional context in comments.

Comments

1

In addition to @user45237841's answer, you can also change the resolution to c or l to resolve this error Unable to open boundary dataset file. Only the 'crude' and 'low', resolution datasets are installed by default.

my_map = Basemap(projection = 'ortho', lat_0=50, lon_0=-100,
            resolution = 'c', area_thresh=1000.0)  
# c is for crude and l is for low

Comments

0

if you are using Jupyter-notebook make sure that using --yes to processing package installing on platform. conda install -c conda-forge basemap-data-hires --yes

Comments

0

If you don't want to update just replace get_axis_bgcolor with get_facecolor in \site-packages\mpl_toolkits\basemap\__init__.py file.

Line 1623:         fill_color = ax.get_facecolor()
Line 1767:         axisbgc = ax.get_facecolor()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.