From dd5b54286f06c19cba3d273e89054db401c2c11c Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Mon, 9 Jan 2023 09:00:23 +0100 Subject: [PATCH] Backport PR #24904: Deprecate AxisArtistHelpers with inconsistent loc/nth_coord. --- doc/api/next_api_changes/deprecations/24904-AL.rst | 4 ++++ lib/mpl_toolkits/axisartist/axislines.py | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/24904-AL.rst 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)) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy