From ccc6fc48fee058ad4a3f7eed8bc114be1d34ae3d Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 12 Jul 2023 09:48:14 +0200 Subject: [PATCH] Deprecate inset_locator.InsetPosition. There's Axes.inset_axes which is an exact replacement without the need of actually understanding what an axes locator is, and which is also more general as one can also set a custom transform on inset_axes instead of being limited to the transAxes of a given parent axes. Also the method had never been used in the library or examples, and a test was only ever added in 6dd30a2 (2022). --- doc/api/next_api_changes/deprecations/26295-AL.rst | 3 +++ lib/mpl_toolkits/axes_grid1/inset_locator.py | 1 + lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 doc/api/next_api_changes/deprecations/26295-AL.rst diff --git a/doc/api/next_api_changes/deprecations/26295-AL.rst b/doc/api/next_api_changes/deprecations/26295-AL.rst new file mode 100644 index 000000000000..f62d40991196 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/26295-AL.rst @@ -0,0 +1,3 @@ +``inset_location.InsetPosition`` is deprecated +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Use `~.Axes.inset_axes` instead. diff --git a/lib/mpl_toolkits/axes_grid1/inset_locator.py b/lib/mpl_toolkits/axes_grid1/inset_locator.py index 9d350510742f..312ab1e887c6 100644 --- a/lib/mpl_toolkits/axes_grid1/inset_locator.py +++ b/lib/mpl_toolkits/axes_grid1/inset_locator.py @@ -13,6 +13,7 @@ from .parasite_axes import HostAxes +@_api.deprecated("3.8", alternative="Axes.inset_axes") class InsetPosition: @_docstring.dedent_interpd def __init__(self, parent, lbwh): diff --git a/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py b/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py index b61574787772..2794f562deb0 100644 --- a/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py +++ b/lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py @@ -691,7 +691,8 @@ def test_rgb_axes(): def test_insetposition(): fig, ax = plt.subplots(figsize=(2, 2)) ax_ins = plt.axes([0, 0, 1, 1]) - ip = InsetPosition(ax, [0.2, 0.25, 0.5, 0.4]) + with pytest.warns(mpl.MatplotlibDeprecationWarning): + ip = InsetPosition(ax, [0.2, 0.25, 0.5, 0.4]) ax_ins.set_axes_locator(ip)