Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions doc/source/users/figures/geos_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl_version = tuple(map(int, mpl.__version__.split(".")))
axkwds = {"axisbg" if mpl_version < (2,) else "facecolor": "k"}
from packaging.version import Version
mpl_version = Version(mpl.__version__)
axkwds = {"axisbg" if mpl_version < Version("2") else "facecolor": "k"}

fig = plt.figure()
# global geostationary map centered on lon_0
Expand Down
5 changes: 3 additions & 2 deletions doc/source/users/figures/nsper_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl_version = tuple(map(int, mpl.__version__.split(".")))
axkwds = {"axisbg" if mpl_version < (2,) else "facecolor": "k"}
from packaging.version import Version
mpl_version = Version(mpl.__version__)
axkwds = {"axisbg" if mpl_version < Version("2") else "facecolor": "k"}

fig = plt.figure()
# global ortho map centered on lon_0,lat_0
Expand Down
5 changes: 3 additions & 2 deletions doc/source/users/figures/ortho_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl_version = tuple(map(int, mpl.__version__.split(".")))
axkwds = {"axisbg" if mpl_version < (2,) else "facecolor": "k"}
from packaging.version import Version
mpl_version = Version(mpl.__version__)
axkwds = {"axisbg" if mpl_version < Version("2") else "facecolor": "k"}

fig = plt.figure()
# global ortho map centered on lon_0,lat_0
Expand Down
10 changes: 6 additions & 4 deletions src/mpl_toolkits/basemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
from matplotlib.transforms import Bbox
from mpl_toolkits.axes_grid1 import make_axes_locatable

from packaging.version import Version

import pyproj
import _geoslib
from . proj import Proj
Expand Down Expand Up @@ -1663,8 +1665,8 @@ def drawmapboundary(self,color='k',linewidth=1.0,fill_color=None,\
# if no fill_color given, use axes background color.
# if fill_color is string 'none', really don't fill.
if fill_color is None:
mpl_version = tuple(map(int, mpl.__version__.split(".")[:2]))
if mpl_version >= (2, 0):
mpl_version = Version(mpl.__version__)
if mpl_version >= Version("2.0"):
fill_color = ax.get_facecolor()
else:
fill_color = ax.get_axis_bgcolor()
Expand Down Expand Up @@ -1762,8 +1764,8 @@ def fillcontinents(self,color='0.8',lake_color=None,ax=None,zorder=None,alpha=No
# get current axes instance (if none specified).
ax = ax or self._check_ax()
# get axis background color.
mpl_version = tuple(map(int, mpl.__version__.split(".")[:2]))
if mpl_version >= (2, 0):
mpl_version = Version(mpl.__version__)
if mpl_version >= Version("2.0"):
axisbgc = ax.get_facecolor()
else:
axisbgc = ax.get_axis_bgcolor()
Expand Down
6 changes: 4 additions & 2 deletions test/mpl_toolkits/basemap/test_Basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
from mpl_toolkits.basemap import Basemap
from mpl_toolkits.basemap import shiftgrid

from packaging.version import Version

try:
import PIL
except ImportError:
PIL = None


mpl_version = tuple(map(int, mpl.__version__.split(".")[:2]))
mpl_version = Version(mpl.__version__)


class TestMplToolkitsBasemapBasemap(unittest.TestCase):
Expand Down Expand Up @@ -199,7 +201,7 @@ def _test_basemap_data_warpimage(self, method, axs=None, axslen0=10):
img = getattr(bmap, method)(ax=axs, scale=0.1)
self.assertIsInstance(img, AxesImage)

flag = int(mpl_version < (3, 5))
flag = int(mpl_version < Version("3.5"))
axs_children = axs_obj.get_children()
self.assertEqual(len(axs_children), axslen0 + 3)
self.assertIsInstance(axs_children[1 - flag], Polygon)
Expand Down