From b4482098a8068d691cb3049e858f8d65a0546872 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 1 Jan 2023 19:24:38 +0000 Subject: [PATCH 1/7] Deprecated _apply_theta_transforms=True --- doc/api/next_api_changes/deprecations/24834-DS.rst | 6 ++++++ lib/matplotlib/projections/polar.py | 11 +++++++++++ lib/matplotlib/text.py | 2 +- .../axisartist/tests/test_floating_axes.py | 4 ++-- .../axisartist/tests/test_grid_helper_curvelinear.py | 6 ++++-- 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/24834-DS.rst diff --git a/doc/api/next_api_changes/deprecations/24834-DS.rst b/doc/api/next_api_changes/deprecations/24834-DS.rst new file mode 100644 index 000000000000..fd6b954d2396 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/24834-DS.rst @@ -0,0 +1,6 @@ +Applying theta transforms in ``PolarTransform`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Applying theta transforms in `~matplotlib.projections.polar.PolarTransform` +is deprecated. This is currently the default behaviour, so to prevent +a warning, manually pass ``_apply_theta_transforms=False``, and +apply any theta shift before passing points to this transform. diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index 25338bca021f..22badf0c7eca 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -52,6 +52,17 @@ def __init__(self, axis=None, use_rmin=True, self._use_rmin = use_rmin self._apply_theta_transforms = _apply_theta_transforms self._scale_transform = scale_transform + if _apply_theta_transforms: + _api.warn_deprecated( + "3.7", + message=( + "Passing `_apply_theta_transforms=True` (the default) " + "is deprecated. Support for this will be removed in " + "Matplotlib %(removal)s. To prevent this warning, " + "set `_apply_theta_transforms=False`, and make sure to " + "shift theta values before being passed to this transform." + ) + ) __str__ = mtransforms._make_str_method( "_axis", diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 8734131dddc9..08109c278372 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -1497,7 +1497,7 @@ def _get_xy_transform(self, renderer, coords): return self.axes.transData elif coords == 'polar': from matplotlib.projections import PolarAxes - tr = PolarAxes.PolarTransform() + tr = PolarAxes.PolarTransform(_apply_theta_transforms=False) trans = tr + self.axes.transData return trans diff --git a/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py b/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py index 31dcf24bb22d..128f97a774f2 100644 --- a/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py +++ b/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py @@ -24,7 +24,7 @@ def test_curvelinear3(): fig = plt.figure(figsize=(5, 5)) tr = (mtransforms.Affine2D().scale(np.pi / 180, 1) + - mprojections.PolarAxes.PolarTransform()) + mprojections.PolarAxes.PolarTransform(_apply_theta_transforms=False)) grid_helper = GridHelperCurveLinear( tr, extremes=(0, 360, 10, 3), @@ -73,7 +73,7 @@ def test_curvelinear4(): fig = plt.figure(figsize=(5, 5)) tr = (mtransforms.Affine2D().scale(np.pi / 180, 1) + - mprojections.PolarAxes.PolarTransform()) + mprojections.PolarAxes.PolarTransform(_apply_theta_transforms=False)) grid_helper = GridHelperCurveLinear( tr, extremes=(120, 30, 10, 0), diff --git a/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py index eb7673fa1fa7..9da862776e82 100644 --- a/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py @@ -82,7 +82,8 @@ def test_polar_box(): # PolarAxes.PolarTransform takes radian. However, we want our coordinate # system in degree - tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform() + tr = (Affine2D().scale(np.pi / 180., 1.) + + PolarAxes.PolarTransform(_apply_theta_transforms=False)) # polar projection, which involves cycle, and also has limits in # its coordinates, needs a special method to find the extremes @@ -144,7 +145,8 @@ def test_axis_direction(): # PolarAxes.PolarTransform takes radian. However, we want our coordinate # system in degree - tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform() + tr = (Affine2D().scale(np.pi / 180., 1.) + + PolarAxes.PolarTransform(_apply_theta_transforms=False)) # polar projection, which involves cycle, and also has limits in # its coordinates, needs a special method to find the extremes From 2c91f982853c1e8df3ac2e68a26170933621356b Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 8 Jan 2023 15:24:25 +0000 Subject: [PATCH 2/7] Deprecate in InvertedPolarTransform --- .../deprecations/24834-DS.rst | 1 + lib/matplotlib/projections/polar.py | 26 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/doc/api/next_api_changes/deprecations/24834-DS.rst b/doc/api/next_api_changes/deprecations/24834-DS.rst index fd6b954d2396..358fa632c5aa 100644 --- a/doc/api/next_api_changes/deprecations/24834-DS.rst +++ b/doc/api/next_api_changes/deprecations/24834-DS.rst @@ -1,6 +1,7 @@ Applying theta transforms in ``PolarTransform`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Applying theta transforms in `~matplotlib.projections.polar.PolarTransform` +and `~matplotlib.projections.polar.InvertedPolarTransform` is deprecated. This is currently the default behaviour, so to prevent a warning, manually pass ``_apply_theta_transforms=False``, and apply any theta shift before passing points to this transform. diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index 22badf0c7eca..f9eaa5f1a815 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -15,6 +15,19 @@ from matplotlib.spines import Spine +def _apply_theta_transforms_warn(): + _api.warn_deprecated( + "3.7", + message=( + "Passing `_apply_theta_transforms=True` (the default) " + "is deprecated. Support for this will be removed in " + "Matplotlib %(removal)s. To prevent this warning, " + "set `_apply_theta_transforms=False`, and make sure to " + "shift theta values before being passed to this transform." + ) + ) + + class PolarTransform(mtransforms.Transform): r""" The base polar transform. @@ -53,16 +66,7 @@ def __init__(self, axis=None, use_rmin=True, self._apply_theta_transforms = _apply_theta_transforms self._scale_transform = scale_transform if _apply_theta_transforms: - _api.warn_deprecated( - "3.7", - message=( - "Passing `_apply_theta_transforms=True` (the default) " - "is deprecated. Support for this will be removed in " - "Matplotlib %(removal)s. To prevent this warning, " - "set `_apply_theta_transforms=False`, and make sure to " - "shift theta values before being passed to this transform." - ) - ) + _apply_theta_transforms_warn() __str__ = mtransforms._make_str_method( "_axis", @@ -220,6 +224,8 @@ def __init__(self, axis=None, use_rmin=True, self._axis = axis self._use_rmin = use_rmin self._apply_theta_transforms = _apply_theta_transforms + if _apply_theta_transforms: + _apply_theta_transforms_warn() __str__ = mtransforms._make_str_method( "_axis", From 1e671bb62928ee898fc317214a3231d0ef338367 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sun, 8 Jan 2023 15:30:03 +0000 Subject: [PATCH 3/7] Fix warnings in examples Fix example --- galleries/examples/axisartist/demo_axis_direction.py | 5 ++++- galleries/examples/axisartist/demo_curvelinear_grid.py | 3 ++- galleries/examples/axisartist/demo_floating_axes.py | 5 +++-- galleries/examples/axisartist/demo_floating_axis.py | 3 ++- galleries/examples/axisartist/simple_axis_pad.py | 3 ++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/galleries/examples/axisartist/demo_axis_direction.py b/galleries/examples/axisartist/demo_axis_direction.py index 00ba40004a59..8c57b6c5a351 100644 --- a/galleries/examples/axisartist/demo_axis_direction.py +++ b/galleries/examples/axisartist/demo_axis_direction.py @@ -20,7 +20,10 @@ def setup_axes(fig, rect): """Polar projection, but in a rectangular box.""" # see demo_curvelinear_grid.py for details grid_helper = GridHelperCurveLinear( - Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform(), + ( + Affine2D().scale(np.pi/180., 1.) + + PolarAxes.PolarTransform(apply_theta_transforms=False) + ), extreme_finder=angle_helper.ExtremeFinderCycle( 20, 20, lon_cycle=360, lat_cycle=None, diff --git a/galleries/examples/axisartist/demo_curvelinear_grid.py b/galleries/examples/axisartist/demo_curvelinear_grid.py index fb1fbdd011ce..fd878b456e10 100644 --- a/galleries/examples/axisartist/demo_curvelinear_grid.py +++ b/galleries/examples/axisartist/demo_curvelinear_grid.py @@ -54,7 +54,8 @@ def curvelinear_test2(fig): # PolarAxes.PolarTransform takes radian. However, we want our coordinate # system in degree - tr = Affine2D().scale(np.pi/180, 1) + PolarAxes.PolarTransform() + tr = Affine2D().scale(np.pi/180, 1) + PolarAxes.PolarTransform( + _apply_theta_transforms=False) # Polar projection, which involves cycle, and also has limits in # its coordinates, needs a special method to find the extremes # (min, max of the coordinate within the view). diff --git a/galleries/examples/axisartist/demo_floating_axes.py b/galleries/examples/axisartist/demo_floating_axes.py index add03e266d3e..7a12612a8a15 100644 --- a/galleries/examples/axisartist/demo_floating_axes.py +++ b/galleries/examples/axisartist/demo_floating_axes.py @@ -54,7 +54,7 @@ def setup_axes2(fig, rect): With custom locator and formatter. Note that the extreme values are swapped. """ - tr = PolarAxes.PolarTransform() + tr = PolarAxes.PolarTransform(_apply_theta_transforms=False) pi = np.pi angle_ticks = [(0, r"$0$"), @@ -99,7 +99,8 @@ def setup_axes3(fig, rect): # scale degree to radians tr_scale = Affine2D().scale(np.pi/180., 1.) - tr = tr_rotate + tr_scale + PolarAxes.PolarTransform() + tr = tr_rotate + tr_scale + PolarAxes.PolarTransform( + _apply_theta_transforms=False) grid_locator1 = angle_helper.LocatorHMS(4) tick_formatter1 = angle_helper.FormatterHMS() diff --git a/galleries/examples/axisartist/demo_floating_axis.py b/galleries/examples/axisartist/demo_floating_axis.py index 0894bf8f4ce1..1dc2999a7aea 100644 --- a/galleries/examples/axisartist/demo_floating_axis.py +++ b/galleries/examples/axisartist/demo_floating_axis.py @@ -22,7 +22,8 @@ def curvelinear_test2(fig): """Polar projection, but in a rectangular box.""" # see demo_curvelinear_grid.py for details - tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform() + tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform( + _apply_theta_transforms=False) extreme_finder = angle_helper.ExtremeFinderCycle(20, 20, diff --git a/galleries/examples/axisartist/simple_axis_pad.py b/galleries/examples/axisartist/simple_axis_pad.py index 7027a88d3549..99c96701caf3 100644 --- a/galleries/examples/axisartist/simple_axis_pad.py +++ b/galleries/examples/axisartist/simple_axis_pad.py @@ -21,7 +21,8 @@ def setup_axes(fig, rect): """Polar projection, but in a rectangular box.""" # see demo_curvelinear_grid.py for details - tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform() + tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform( + _apply_theta_transforms=False) extreme_finder = angle_helper.ExtremeFinderCycle(20, 20, lon_cycle=360, From 10453dbde447855e13388d902f65a3afbb24d9c8 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Sat, 18 Feb 2023 09:08:25 +0000 Subject: [PATCH 4/7] Make _apply_theta_transforms public --- .../deprecations/24834-DS.rst | 15 ++++++-- .../axisartist/demo_curvelinear_grid.py | 2 +- .../examples/axisartist/demo_floating_axes.py | 4 +-- .../examples/axisartist/demo_floating_axis.py | 2 +- .../examples/axisartist/simple_axis_pad.py | 2 +- lib/matplotlib/projections/polar.py | 36 ++++++++++--------- lib/matplotlib/tests/test_transforms.py | 2 +- lib/matplotlib/text.py | 2 +- .../axisartist/tests/test_floating_axes.py | 4 +-- .../tests/test_grid_helper_curvelinear.py | 4 +-- 10 files changed, 43 insertions(+), 30 deletions(-) diff --git a/doc/api/next_api_changes/deprecations/24834-DS.rst b/doc/api/next_api_changes/deprecations/24834-DS.rst index 358fa632c5aa..ef7132c7d6d7 100644 --- a/doc/api/next_api_changes/deprecations/24834-DS.rst +++ b/doc/api/next_api_changes/deprecations/24834-DS.rst @@ -2,6 +2,15 @@ Applying theta transforms in ``PolarTransform`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Applying theta transforms in `~matplotlib.projections.polar.PolarTransform` and `~matplotlib.projections.polar.InvertedPolarTransform` -is deprecated. This is currently the default behaviour, so to prevent -a warning, manually pass ``_apply_theta_transforms=False``, and -apply any theta shift before passing points to this transform. +is deprecated, and will be removed in a future version of Matplotlib. This +is currently the default behaviour when these transforms are used externally, +but only takes affect when: + +- An axis is associated with the transform. +- The axis has a non-zero theta offset or has theta values increasing in + a clockwise direction. + +To silence this warning and adopt future behaviour, +set ``apply_theta_transforms=False``. If you need to retain the behaviour +where theta values are transformed, chain the ``PolarTransform`` with +another transform that performs the theta shift and/or sign shift. diff --git a/galleries/examples/axisartist/demo_curvelinear_grid.py b/galleries/examples/axisartist/demo_curvelinear_grid.py index fd878b456e10..40853dee12cb 100644 --- a/galleries/examples/axisartist/demo_curvelinear_grid.py +++ b/galleries/examples/axisartist/demo_curvelinear_grid.py @@ -55,7 +55,7 @@ def curvelinear_test2(fig): # PolarAxes.PolarTransform takes radian. However, we want our coordinate # system in degree tr = Affine2D().scale(np.pi/180, 1) + PolarAxes.PolarTransform( - _apply_theta_transforms=False) + apply_theta_transforms=False) # Polar projection, which involves cycle, and also has limits in # its coordinates, needs a special method to find the extremes # (min, max of the coordinate within the view). diff --git a/galleries/examples/axisartist/demo_floating_axes.py b/galleries/examples/axisartist/demo_floating_axes.py index 7a12612a8a15..632f6d237aa6 100644 --- a/galleries/examples/axisartist/demo_floating_axes.py +++ b/galleries/examples/axisartist/demo_floating_axes.py @@ -54,7 +54,7 @@ def setup_axes2(fig, rect): With custom locator and formatter. Note that the extreme values are swapped. """ - tr = PolarAxes.PolarTransform(_apply_theta_transforms=False) + tr = PolarAxes.PolarTransform(apply_theta_transforms=False) pi = np.pi angle_ticks = [(0, r"$0$"), @@ -100,7 +100,7 @@ def setup_axes3(fig, rect): tr_scale = Affine2D().scale(np.pi/180., 1.) tr = tr_rotate + tr_scale + PolarAxes.PolarTransform( - _apply_theta_transforms=False) + apply_theta_transforms=False) grid_locator1 = angle_helper.LocatorHMS(4) tick_formatter1 = angle_helper.FormatterHMS() diff --git a/galleries/examples/axisartist/demo_floating_axis.py b/galleries/examples/axisartist/demo_floating_axis.py index 1dc2999a7aea..5296b682367b 100644 --- a/galleries/examples/axisartist/demo_floating_axis.py +++ b/galleries/examples/axisartist/demo_floating_axis.py @@ -23,7 +23,7 @@ def curvelinear_test2(fig): """Polar projection, but in a rectangular box.""" # see demo_curvelinear_grid.py for details tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform( - _apply_theta_transforms=False) + apply_theta_transforms=False) extreme_finder = angle_helper.ExtremeFinderCycle(20, 20, diff --git a/galleries/examples/axisartist/simple_axis_pad.py b/galleries/examples/axisartist/simple_axis_pad.py index 99c96701caf3..9c613c820b2b 100644 --- a/galleries/examples/axisartist/simple_axis_pad.py +++ b/galleries/examples/axisartist/simple_axis_pad.py @@ -22,7 +22,7 @@ def setup_axes(fig, rect): # see demo_curvelinear_grid.py for details tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform( - _apply_theta_transforms=False) + apply_theta_transforms=False) extreme_finder = angle_helper.ExtremeFinderCycle(20, 20, lon_cycle=360, diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index f9eaa5f1a815..726b0ee3901b 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -19,10 +19,10 @@ def _apply_theta_transforms_warn(): _api.warn_deprecated( "3.7", message=( - "Passing `_apply_theta_transforms=True` (the default) " + "Passing `apply_theta_transforms=True` (the default) " "is deprecated. Support for this will be removed in " "Matplotlib %(removal)s. To prevent this warning, " - "set `_apply_theta_transforms=False`, and make sure to " + "set `apply_theta_transforms=False`, and make sure to " "shift theta values before being passed to this transform." ) ) @@ -47,8 +47,8 @@ class PolarTransform(mtransforms.Transform): input_dims = output_dims = 2 - def __init__(self, axis=None, use_rmin=True, - _apply_theta_transforms=True, *, scale_transform=None): + def __init__(self, axis=None, use_rmin=True, *, + apply_theta_transforms=True, scale_transform=None): """ Parameters ---------- @@ -63,15 +63,15 @@ def __init__(self, axis=None, use_rmin=True, super().__init__() self._axis = axis self._use_rmin = use_rmin - self._apply_theta_transforms = _apply_theta_transforms + self._apply_theta_transforms = apply_theta_transforms self._scale_transform = scale_transform - if _apply_theta_transforms: + if apply_theta_transforms: _apply_theta_transforms_warn() __str__ = mtransforms._make_str_method( "_axis", use_rmin="_use_rmin", - _apply_theta_transforms="_apply_theta_transforms") + apply_theta_transforms="_apply_theta_transforms") def _get_rorigin(self): # Get lower r limit after being scaled by the radial scale transform @@ -148,8 +148,10 @@ def transform_path_non_affine(self, path): def inverted(self): # docstring inherited - return PolarAxes.InvertedPolarTransform(self._axis, self._use_rmin, - self._apply_theta_transforms) + return PolarAxes.InvertedPolarTransform( + self._axis, self._use_rmin, + apply_theta_transforms=self._apply_theta_transforms + ) class PolarAffine(mtransforms.Affine2DBase): @@ -208,7 +210,7 @@ class InvertedPolarTransform(mtransforms.Transform): input_dims = output_dims = 2 def __init__(self, axis=None, use_rmin=True, - _apply_theta_transforms=True): + *, apply_theta_transforms=True): """ Parameters ---------- @@ -223,14 +225,14 @@ def __init__(self, axis=None, use_rmin=True, super().__init__() self._axis = axis self._use_rmin = use_rmin - self._apply_theta_transforms = _apply_theta_transforms - if _apply_theta_transforms: + self._apply_theta_transforms = apply_theta_transforms + if apply_theta_transforms: _apply_theta_transforms_warn() __str__ = mtransforms._make_str_method( "_axis", use_rmin="_use_rmin", - _apply_theta_transforms="_apply_theta_transforms") + apply_theta_transforms="_apply_theta_transforms") @_api.rename_parameter("3.8", "xy", "values") def transform_non_affine(self, values): @@ -251,8 +253,10 @@ def transform_non_affine(self, values): def inverted(self): # docstring inherited - return PolarAxes.PolarTransform(self._axis, self._use_rmin, - self._apply_theta_transforms) + return PolarAxes.PolarTransform( + self._axis, self._use_rmin, + apply_theta_transforms=self._apply_theta_transforms + ) class ThetaFormatter(mticker.Formatter): @@ -896,7 +900,7 @@ def _set_lim_and_transforms(self): # data. This one is aware of rmin self.transProjection = self.PolarTransform( self, - _apply_theta_transforms=False, + apply_theta_transforms=False, scale_transform=self.transScale ) # Add dependency on rorigin. diff --git a/lib/matplotlib/tests/test_transforms.py b/lib/matplotlib/tests/test_transforms.py index 95e76ad95c4f..959814de82db 100644 --- a/lib/matplotlib/tests/test_transforms.py +++ b/lib/matplotlib/tests/test_transforms.py @@ -859,7 +859,7 @@ def test_str_transform(): PolarTransform( PolarAxes(0.125,0.1;0.775x0.8), use_rmin=True, - _apply_theta_transforms=False)), + apply_theta_transforms=False)), CompositeGenericTransform( CompositeGenericTransform( PolarAffine( diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 08109c278372..dcf1b7558b9f 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -1497,7 +1497,7 @@ def _get_xy_transform(self, renderer, coords): return self.axes.transData elif coords == 'polar': from matplotlib.projections import PolarAxes - tr = PolarAxes.PolarTransform(_apply_theta_transforms=False) + tr = PolarAxes.PolarTransform(apply_theta_transforms=False) trans = tr + self.axes.transData return trans diff --git a/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py b/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py index 128f97a774f2..7644fea16965 100644 --- a/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py +++ b/lib/mpl_toolkits/axisartist/tests/test_floating_axes.py @@ -24,7 +24,7 @@ def test_curvelinear3(): fig = plt.figure(figsize=(5, 5)) tr = (mtransforms.Affine2D().scale(np.pi / 180, 1) + - mprojections.PolarAxes.PolarTransform(_apply_theta_transforms=False)) + mprojections.PolarAxes.PolarTransform(apply_theta_transforms=False)) grid_helper = GridHelperCurveLinear( tr, extremes=(0, 360, 10, 3), @@ -73,7 +73,7 @@ def test_curvelinear4(): fig = plt.figure(figsize=(5, 5)) tr = (mtransforms.Affine2D().scale(np.pi / 180, 1) + - mprojections.PolarAxes.PolarTransform(_apply_theta_transforms=False)) + mprojections.PolarAxes.PolarTransform(apply_theta_transforms=False)) grid_helper = GridHelperCurveLinear( tr, extremes=(120, 30, 10, 0), diff --git a/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py index 9da862776e82..8e6aded047fe 100644 --- a/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py @@ -83,7 +83,7 @@ def test_polar_box(): # PolarAxes.PolarTransform takes radian. However, we want our coordinate # system in degree tr = (Affine2D().scale(np.pi / 180., 1.) + - PolarAxes.PolarTransform(_apply_theta_transforms=False)) + PolarAxes.PolarTransform(apply_theta_transforms=False)) # polar projection, which involves cycle, and also has limits in # its coordinates, needs a special method to find the extremes @@ -146,7 +146,7 @@ def test_axis_direction(): # PolarAxes.PolarTransform takes radian. However, we want our coordinate # system in degree tr = (Affine2D().scale(np.pi / 180., 1.) + - PolarAxes.PolarTransform(_apply_theta_transforms=False)) + PolarAxes.PolarTransform(apply_theta_transforms=False)) # polar projection, which involves cycle, and also has limits in # its coordinates, needs a special method to find the extremes From 0a62fccd4c9da4bda7c8274b9e5bc1657294125c Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 28 Dec 2023 18:00:01 +0000 Subject: [PATCH 5/7] Fix polar type stubs --- lib/matplotlib/projections/polar.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/projections/polar.pyi b/lib/matplotlib/projections/polar.pyi index 2592d4947184..de1cbc293900 100644 --- a/lib/matplotlib/projections/polar.pyi +++ b/lib/matplotlib/projections/polar.pyi @@ -17,8 +17,8 @@ class PolarTransform(mtransforms.Transform): self, axis: PolarAxes | None = ..., use_rmin: bool = ..., - _apply_theta_transforms: bool = ..., *, + apply_theta_transforms: bool = ..., scale_transform: mtransforms.Transform | None = ..., ) -> None: ... def inverted(self) -> InvertedPolarTransform: ... @@ -35,7 +35,8 @@ class InvertedPolarTransform(mtransforms.Transform): self, axis: PolarAxes | None = ..., use_rmin: bool = ..., - _apply_theta_transforms: bool = ..., + *, + apply_theta_transforms: bool = ..., ) -> None: ... def inverted(self) -> PolarTransform: ... From dbda379de3cf49e8bb67b3a7aa86e547ec26fdec Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 28 Dec 2023 21:00:35 +0000 Subject: [PATCH 6/7] Update deprecation message --- lib/matplotlib/projections/polar.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/projections/polar.py b/lib/matplotlib/projections/polar.py index 726b0ee3901b..60eb5a2920f3 100644 --- a/lib/matplotlib/projections/polar.py +++ b/lib/matplotlib/projections/polar.py @@ -17,13 +17,14 @@ def _apply_theta_transforms_warn(): _api.warn_deprecated( - "3.7", + "3.9", message=( "Passing `apply_theta_transforms=True` (the default) " - "is deprecated. Support for this will be removed in " - "Matplotlib %(removal)s. To prevent this warning, " - "set `apply_theta_transforms=False`, and make sure to " - "shift theta values before being passed to this transform." + "is deprecated since Matplotlib %(since)s. " + "Support for this will be removed in Matplotlib %(removal)s. " + "To prevent this warning, set `apply_theta_transforms=False`, " + "and make sure to shift theta values before being passed to " + "this transform." ) ) From ee48fb30f462e3504d3c63fd13cf5a02027adfb5 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Thu, 28 Dec 2023 21:03:19 +0000 Subject: [PATCH 7/7] Update api note --- doc/api/next_api_changes/deprecations/24834-DS.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/deprecations/24834-DS.rst b/doc/api/next_api_changes/deprecations/24834-DS.rst index ef7132c7d6d7..3761daaf1275 100644 --- a/doc/api/next_api_changes/deprecations/24834-DS.rst +++ b/doc/api/next_api_changes/deprecations/24834-DS.rst @@ -13,4 +13,5 @@ but only takes affect when: To silence this warning and adopt future behaviour, set ``apply_theta_transforms=False``. If you need to retain the behaviour where theta values are transformed, chain the ``PolarTransform`` with -another transform that performs the theta shift and/or sign shift. +a `~matplotlib.transforms.Affine2D` transform that performs the theta shift +and/or sign shift.