Skip to content

Commit 813c7b9

Browse files
authored
Merge pull request #257 from raphaelquast/dev
V8.3.2
2 parents 66d32e2 + 8fca057 commit 813c7b9

File tree

15 files changed

+71
-35
lines changed

15 files changed

+71
-35
lines changed

.readthedocs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
version: 2
22

3+
sphinx:
4+
configuration: docs/source/conf.py
5+
36
build:
47
os: "ubuntu-20.04"
58
tools:

docs/source/FAQ.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ However, for some editors there are special settings that can be adjusted to imp
9595

9696
To print a snapshot of the current state of a figure to the IPython terminal, call :py:meth:`Maps.show` or :py:meth:`Maps.snapshot`.
9797

98-
- Similar to Jupyter Notebooks, you can use *"magic"* commands to set the used matpltolib backend.
98+
- Similar to Jupyter Notebooks, you can use *"magic"* commands to set the used matplotlib backend.
9999

100100
- For interactive (popup) figures, switch to the default Qt backend using ``%matplotlib qt``
101101
- For interactive (inline) figures, you'll need to install `ipympl <https://github.com/matplotlib/ipympl>`_ and then activate the ``widget`` with ``%matplotlib widget``.

docs/source/_static/version_switcher.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"url": "https://eomaps.readthedocs.io/en/dev/"
1010
},
1111
{
12-
"version": "v8.3",
13-
"url": "https://eomaps.readthedocs.io/en/v8.3/"
12+
"version": "v8.3.2",
13+
"url": "https://eomaps.readthedocs.io/en/v8.3.2/"
1414
},
1515
{
1616
"version": "v8.2.1",

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def mpl_rc_role_subst(name, rawtext, text, lineno, inliner, options={}, content=
5656

5757
node = reference(
5858
"",
59-
f"matpltolib rcParams['{text}']",
59+
f"matplotlib rcParams['{text}']",
6060
refuri=r"https://matplotlib.org/stable/users/explain/customizing.html#matplotlibrc-sample",
6161
)
6262
return [node], []

docs/source/user_guide/how_to_use/api_basics.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ To adjust the margins of the subplots, use :py:meth:`m.subplots_adjust`, or have
393393
Multiple Maps/Plots in one Figure
394394
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395395

396-
It is possible to combine multiple ``EOmaps`` maps and/or ordinary ``matpltolib`` plots in one figure.
396+
It is possible to combine multiple ``EOmaps`` maps and/or ordinary ``matplotlib`` plots in one figure.
397397

398398
The **figure** used by a :py:class:`Maps` object is set via the ``f`` argument, e.g.: ``m = Maps(f=...)``.
399399
If no figure is provided, a new figure is created whenever you initialize a :py:class:`Maps` object.
@@ -714,7 +714,7 @@ MapsGrid objects
714714
the preferred way of combining multiple maps and/or matplotlib axes in a figure
715715
is by using one of the options presented in the previous sections!
716716

717-
A :py:class:`MapsGrid` creates a grid of :py:class:`Maps` objects (and/or ordinary ``matpltolib`` axes),
717+
A :py:class:`MapsGrid` creates a grid of :py:class:`Maps` objects (and/or ordinary ``matplotlib`` axes),
718718
and provides convenience-functions to perform actions on all maps of the figure.
719719

720720
.. code-block:: python
@@ -768,7 +768,7 @@ of the following structure:
768768
- ``m_inits`` is used to initialize :py:class:`Maps` objects
769769
- ``ax_inits`` is used to initialize ordinary ``matplotlib`` axes
770770

771-
The individual :py:class:`Maps` objects and ``matpltolib-Axes`` are then accessible via:
771+
The individual :py:class:`Maps` objects and ``matplotlib-Axes`` are then accessible via:
772772

773773
.. code-block:: python
774774
:name: test_mapsgrid_custom

docs/source/user_guide/how_to_use/api_data_visualization.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ Colors can also be set **manually** by providing one of the following arguments
878878
Uniform colors
879879
**************
880880

881-
To apply a uniform color to all datapoints, you can use `matpltolib's named colors <https://matplotlib.org/stable/gallery/color/named_colors.html>`_ or pass an RGB or RGBA tuple.
881+
To apply a uniform color to all datapoints, you can use `matplotlib's named colors <https://matplotlib.org/stable/gallery/color/named_colors.html>`_ or pass an RGB or RGBA tuple.
882882

883883
- ``m.plot_map(fc="orange")``
884884
- ``m.plot_map(fc=(0.4, 0.3, 0.2))``

eomaps/_blit_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ def remove_artist(self, art, layer=None):
10811081
10821082
Parameters
10831083
----------
1084-
art : matpltolib.Artist
1084+
art : matplotlib.Artist
10851085
The artist to remove.
10861086
layer : str, optional
10871087
The layer to search for the artist. If None, all layers are searched.
@@ -1403,7 +1403,7 @@ def blit_artists(self, artists, bg="active", blit=True):
14031403
----------
14041404
artists : iterable
14051405
the artists to draw
1406-
bg : matpltolib.BufferRegion, None or "active", optional
1406+
bg : matplotlib.BufferRegion, None or "active", optional
14071407
A fetched background that is restored before drawing the artists.
14081408
The default is "active".
14091409
blit : bool

eomaps/_maps_base.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,21 +439,14 @@ def parent(self):
439439

440440
def _init_figure(self, **kwargs):
441441
if self.parent.f is None:
442-
# do this on any new figure since "%matpltolib inline" tries to re-activate
442+
# do this on any new figure since "%matplotlib inline" tries to re-activate
443443
# interactive mode all the time!
444444
_handle_backends()
445445

446446
self._f = plt.figure(**kwargs)
447447
# to hide canvas header in jupyter notebooks (default figure label)
448448
self._f.canvas.header_visible = False
449449

450-
# override Figure.savefig with Maps.savefig but keep original
451-
# method accessible via Figure._mpl_orig_savefig
452-
# (this ensures that using the save-buttons in the gui or pressing
453-
# control+s will redirect the save process to the eomaps routine)
454-
self._f._mpl_orig_savefig = self._f.savefig
455-
self._f.savefig = self.savefig
456-
457450
_log.debug("EOmaps: New figure created")
458451

459452
# make sure we keep a "real" reference otherwise overwriting the
@@ -466,6 +459,14 @@ def _init_figure(self, **kwargs):
466459
self.parent._add_child(self)
467460

468461
if self.parent == self: # use == instead of "is" since the parent is a proxy!
462+
463+
# override Figure.savefig with Maps.savefig but keep original
464+
# method accessible via Figure._mpl_orig_savefig
465+
# (this ensures that using the save-buttons in the gui or pressing
466+
# control+s will redirect the save process to the eomaps routine)
467+
self._f._mpl_orig_savefig = self._f.savefig
468+
self._f.savefig = self.savefig
469+
469470
# only attach resize- and close-callbacks if we initialize a parent
470471
# Maps-object
471472
# attach a callback that is executed when the figure is closed
@@ -1160,6 +1161,20 @@ def crs_plot(self):
11601161
@staticmethod
11611162
@lru_cache()
11621163
def _get_cartopy_crs(crs):
1164+
if isinstance(crs, str):
1165+
try:
1166+
# TODO use crs=int(crs.upper().removeprefix("EPSG:")) when python>=3.9
1167+
# is required
1168+
crs = crs.upper()
1169+
if crs.startswith("EPSG:"):
1170+
crs = crs[5:]
1171+
crs = int(crs)
1172+
except ValueError:
1173+
raise ValueError(
1174+
f"The provided crs '{crs}' cannot be identified. "
1175+
"If a string is provided as CRS, it must be either an integer "
1176+
"(e.g. '4326') or a string of the form: 'EPSG:4326'."
1177+
)
11631178
if isinstance(crs, ccrs.CRS): # already a cartopy CRS
11641179
cartopy_proj = crs
11651180
elif crs == 4326:

eomaps/_webmap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def add_legend(self, style=None, img=None):
132132
133133
Returns
134134
-------
135-
legax : matpltolib.axes
135+
legax : matplotlib.axes
136136
The axes-object.
137137
138138
"""

eomaps/colorbar.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import numpy as np
1212

13-
from .helpers import _TransformedBoundsLocator, pairwise
13+
from .helpers import _TransformedBoundsLocator, pairwise, version, mpl_version
1414

1515
import logging
1616

@@ -943,7 +943,13 @@ def indicate_contours(
943943
else:
944944
coll = contour_map.coll
945945

946-
if not coll.__class__.__name__ == "_CollectionAccessor":
946+
# TODO remove this once mpl >=3.10 is required
947+
if mpl_version < version.Version("3.10"):
948+
expected_collections = ["_CollectionAccessor"]
949+
else:
950+
expected_collections = ["ContourSet", "TriContourSet", "GeoContourSet"]
951+
952+
if not coll.__class__.__name__ in expected_collections:
947953
raise TypeError(
948954
"EOmaps: Contour-lines can only be added to the colorbar if a contour "
949955
"was plotted first! If you want to indicate contours plotted on a "
@@ -958,7 +964,11 @@ def indicate_contours(
958964
exclude_levels[i] = len(levels) + val
959965

960966
if colors is None:
961-
if coll._filled is False:
967+
# _filled is required for mpl <3.10 (e.g. _CollectionAccessor)
968+
# TODO use only "coll.filled" once mpl >=3.10 is required
969+
filled = coll._filled if hasattr(coll, "_filled") else coll.filled
970+
971+
if filled is False:
962972
colors = (
963973
np.array(coll.get_edgecolors(), dtype=object).squeeze().tolist()
964974
)

0 commit comments

Comments
 (0)