diff --git a/doc/api/next_api_changes/deprecations/24904-AL.rst b/doc/api/next_api_changes/deprecations/24904-AL.rst new file mode 100644 index 000000000000..cbd04aadd3d8 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/24904-AL.rst @@ -0,0 +1,4 @@ +Passing inconsistent ``loc`` and ``nth_coord`` to axisartist helpers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Trying to construct for example a "top y-axis" or a "left x-axis" is now +deprecated. diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index 081fdadb0835..36c1a004b78d 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -126,12 +126,17 @@ class Fixed(_Base): def __init__(self, loc, nth_coord=None): """``nth_coord = 0``: x-axis; ``nth_coord = 1``: y-axis.""" - _api.check_in_list(["left", "right", "bottom", "top"], loc=loc) - self._loc = loc - self._pos = {"bottom": 0, "top": 1, "left": 0, "right": 1}[loc] self.nth_coord = ( nth_coord if nth_coord is not None else - {"bottom": 0, "top": 0, "left": 1, "right": 1}[loc]) + _api.check_getitem( + {"bottom": 0, "top": 0, "left": 1, "right": 1}, loc=loc)) + if (nth_coord == 0 and loc not in ["left", "right"] + or nth_coord == 1 and loc not in ["bottom", "top"]): + _api.warn_deprecated( + "3.7", message=f"{loc=!r} is incompatible with " + "{nth_coord=}; support is deprecated since %(since)s") + self._loc = loc + self._pos = {"bottom": 0, "top": 1, "left": 0, "right": 1}[loc] super().__init__() # axis line in transAxes self._path = Path(self._to_xy((0, 1), const=self._pos))