From bc159935b716882c68364f7181d421c338c63586 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sat, 7 Jan 2023 11:44:09 +0100 Subject: [PATCH] Deprecate AxisArtistHelpers with inconsistent loc/nth_coord. A "top y-axis" or a "left x-axis" doesn't make sense. --- 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