Skip to content

Commit becb291

Browse files
committed
Merge pull request #292 from WeatherGod/fix_bg_warning
Avoid using deprecated get_axis_bgcolor() method with newer matplotlib
2 parents c58de50 + eed9733 commit becb291

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
1313
:func:`addcyclic`: Add cyclic (wraparound) point in longitude.
1414
"""
15+
from distutils.version import LooseVersion
1516
from matplotlib import __version__ as _matplotlib_version
1617
from matplotlib.cbook import is_scalar, dedent
1718
# check to make sure matplotlib is not too old.
18-
_mpl_required_version = '0.98'
19+
_matplotlib_version = LooseVersion(_matplotlib_version)
20+
_mpl_required_version = LooseVersion('0.98')
1921
if _matplotlib_version < _mpl_required_version:
2022
msg = dedent("""
2123
your matplotlib is too old - basemap requires version %s or
@@ -1649,7 +1651,10 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
16491651
# if no fill_color given, use axes background color.
16501652
# if fill_color is string 'none', really don't fill.
16511653
if fill_color is None:
1652-
fill_color = ax.get_axis_bgcolor()
1654+
if _matplotlib_version >= '2.0':
1655+
fill_color = ax.get_facecolor()
1656+
else:
1657+
fill_color = ax.get_axis_bgcolor()
16531658
elif fill_color == 'none' or fill_color == 'None':
16541659
fill_color = None
16551660
limb = None
@@ -1744,7 +1749,10 @@ def fillcontinents(self,color='0.8',lake_color=None,ax=None,zorder=None,alpha=No
17441749
# get current axes instance (if none specified).
17451750
ax = ax or self._check_ax()
17461751
# get axis background color.
1747-
axisbgc = ax.get_axis_bgcolor()
1752+
if _matplotlib_version >= '1.5':
1753+
axisbgc = ax.get_facecolor()
1754+
else:
1755+
axisbgc = ax.get_axis_bgcolor()
17481756
npoly = 0
17491757
polys = []
17501758
for x,y in self.coastpolygons:

0 commit comments

Comments
 (0)