Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6083ecd

Browse files
authored
Remove apply_theta_transforms argument (#30004)
* Remove apply_theta_transforms argument * Improve formatting * Rename xxxxxx-DS.rst to 30004-DS.rst * Delete extra line
1 parent b2a9748 commit 6083ecd

File tree

13 files changed

+29
-76
lines changed

13 files changed

+29
-76
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
``apply_theta_transforms`` option in ``PolarTransform``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Applying theta transforms in `~matplotlib.projections.polar.PolarTransform` and
5+
`~matplotlib.projections.polar.InvertedPolarTransform` has been removed, and
6+
the ``apply_theta_transforms`` keyword argument removed from both classes.
7+
8+
If you need to retain the behaviour where theta values
9+
are transformed, chain the ``PolarTransform`` with a `~matplotlib.transforms.Affine2D`
10+
transform that performs the theta shift and/or sign shift.

doc/api/next_api_changes/removals/xxxxxx-DS.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

galleries/examples/axisartist/demo_axis_direction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def setup_axes(fig, rect):
2222
grid_helper = GridHelperCurveLinear(
2323
(
2424
Affine2D().scale(np.pi/180., 1.) +
25-
PolarAxes.PolarTransform(apply_theta_transforms=False)
25+
PolarAxes.PolarTransform()
2626
),
2727
extreme_finder=angle_helper.ExtremeFinderCycle(
2828
20, 20,

galleries/examples/axisartist/demo_curvelinear_grid.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def curvelinear_test2(fig):
5454

5555
# PolarAxes.PolarTransform takes radian. However, we want our coordinate
5656
# system in degree
57-
tr = Affine2D().scale(np.pi/180, 1) + PolarAxes.PolarTransform(
58-
apply_theta_transforms=False)
57+
tr = Affine2D().scale(np.pi/180, 1) + PolarAxes.PolarTransform()
5958
# Polar projection, which involves cycle, and also has limits in
6059
# its coordinates, needs a special method to find the extremes
6160
# (min, max of the coordinate within the view).

galleries/examples/axisartist/demo_floating_axes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def setup_axes2(fig, rect):
5454
With custom locator and formatter.
5555
Note that the extreme values are swapped.
5656
"""
57-
tr = PolarAxes.PolarTransform(apply_theta_transforms=False)
57+
tr = PolarAxes.PolarTransform()
5858

5959
pi = np.pi
6060
angle_ticks = [(0, r"$0$"),
@@ -99,8 +99,7 @@ def setup_axes3(fig, rect):
9999
# scale degree to radians
100100
tr_scale = Affine2D().scale(np.pi/180., 1.)
101101

102-
tr = tr_rotate + tr_scale + PolarAxes.PolarTransform(
103-
apply_theta_transforms=False)
102+
tr = tr_rotate + tr_scale + PolarAxes.PolarTransform()
104103

105104
grid_locator1 = angle_helper.LocatorHMS(4)
106105
tick_formatter1 = angle_helper.FormatterHMS()

galleries/examples/axisartist/demo_floating_axis.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
def curvelinear_test2(fig):
2323
"""Polar projection, but in a rectangular box."""
2424
# see demo_curvelinear_grid.py for details
25-
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform(
26-
apply_theta_transforms=False)
25+
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform()
2726

2827
extreme_finder = angle_helper.ExtremeFinderCycle(20,
2928
20,

galleries/examples/axisartist/simple_axis_pad.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def setup_axes(fig, rect):
2121
"""Polar projection, but in a rectangular box."""
2222

2323
# see demo_curvelinear_grid.py for details
24-
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform(
25-
apply_theta_transforms=False)
24+
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
2625

2726
extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
2827
lon_cycle=360,

lib/matplotlib/projections/polar.py

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@
1515
from matplotlib.spines import Spine
1616

1717

18-
def _apply_theta_transforms_warn():
19-
_api.warn_deprecated(
20-
"3.9",
21-
message=(
22-
"Passing `apply_theta_transforms=True` (the default) "
23-
"is deprecated since Matplotlib %(since)s. "
24-
"Support for this will be removed in Matplotlib in %(removal)s. "
25-
"To prevent this warning, set `apply_theta_transforms=False`, "
26-
"and make sure to shift theta values before being passed to "
27-
"this transform."
28-
)
29-
)
30-
31-
3218
class PolarTransform(mtransforms.Transform):
3319
r"""
3420
The base polar transform.
@@ -48,8 +34,7 @@ class PolarTransform(mtransforms.Transform):
4834

4935
input_dims = output_dims = 2
5036

51-
def __init__(self, axis=None, use_rmin=True, *,
52-
apply_theta_transforms=True, scale_transform=None):
37+
def __init__(self, axis=None, use_rmin=True, *, scale_transform=None):
5338
"""
5439
Parameters
5540
----------
@@ -64,15 +49,12 @@ def __init__(self, axis=None, use_rmin=True, *,
6449
super().__init__()
6550
self._axis = axis
6651
self._use_rmin = use_rmin
67-
self._apply_theta_transforms = apply_theta_transforms
6852
self._scale_transform = scale_transform
69-
if apply_theta_transforms:
70-
_apply_theta_transforms_warn()
7153

7254
__str__ = mtransforms._make_str_method(
7355
"_axis",
74-
use_rmin="_use_rmin",
75-
apply_theta_transforms="_apply_theta_transforms")
56+
use_rmin="_use_rmin"
57+
)
7658

7759
def _get_rorigin(self):
7860
# Get lower r limit after being scaled by the radial scale transform
@@ -82,11 +64,6 @@ def _get_rorigin(self):
8264
def transform_non_affine(self, values):
8365
# docstring inherited
8466
theta, r = np.transpose(values)
85-
# PolarAxes does not use the theta transforms here, but apply them for
86-
# backwards-compatibility if not being used by it.
87-
if self._apply_theta_transforms and self._axis is not None:
88-
theta *= self._axis.get_theta_direction()
89-
theta += self._axis.get_theta_offset()
9067
if self._use_rmin and self._axis is not None:
9168
r = (r - self._get_rorigin()) * self._axis.get_rsign()
9269
r = np.where(r >= 0, r, np.nan)
@@ -148,10 +125,7 @@ def transform_path_non_affine(self, path):
148125

149126
def inverted(self):
150127
# docstring inherited
151-
return PolarAxes.InvertedPolarTransform(
152-
self._axis, self._use_rmin,
153-
apply_theta_transforms=self._apply_theta_transforms
154-
)
128+
return PolarAxes.InvertedPolarTransform(self._axis, self._use_rmin)
155129

156130

157131
class PolarAffine(mtransforms.Affine2DBase):
@@ -209,8 +183,7 @@ class InvertedPolarTransform(mtransforms.Transform):
209183
"""
210184
input_dims = output_dims = 2
211185

212-
def __init__(self, axis=None, use_rmin=True,
213-
*, apply_theta_transforms=True):
186+
def __init__(self, axis=None, use_rmin=True):
214187
"""
215188
Parameters
216189
----------
@@ -225,37 +198,24 @@ def __init__(self, axis=None, use_rmin=True,
225198
super().__init__()
226199
self._axis = axis
227200
self._use_rmin = use_rmin
228-
self._apply_theta_transforms = apply_theta_transforms
229-
if apply_theta_transforms:
230-
_apply_theta_transforms_warn()
231201

232202
__str__ = mtransforms._make_str_method(
233203
"_axis",
234-
use_rmin="_use_rmin",
235-
apply_theta_transforms="_apply_theta_transforms")
204+
use_rmin="_use_rmin")
236205

237206
def transform_non_affine(self, values):
238207
# docstring inherited
239208
x, y = values.T
240209
r = np.hypot(x, y)
241210
theta = (np.arctan2(y, x) + 2 * np.pi) % (2 * np.pi)
242-
# PolarAxes does not use the theta transforms here, but apply them for
243-
# backwards-compatibility if not being used by it.
244-
if self._apply_theta_transforms and self._axis is not None:
245-
theta -= self._axis.get_theta_offset()
246-
theta *= self._axis.get_theta_direction()
247-
theta %= 2 * np.pi
248211
if self._use_rmin and self._axis is not None:
249212
r += self._axis.get_rorigin()
250213
r *= self._axis.get_rsign()
251214
return np.column_stack([theta, r])
252215

253216
def inverted(self):
254217
# docstring inherited
255-
return PolarAxes.PolarTransform(
256-
self._axis, self._use_rmin,
257-
apply_theta_transforms=self._apply_theta_transforms
258-
)
218+
return PolarAxes.PolarTransform(self._axis, self._use_rmin)
259219

260220

261221
class ThetaFormatter(mticker.Formatter):
@@ -895,7 +855,6 @@ def _set_lim_and_transforms(self):
895855
# data. This one is aware of rmin
896856
self.transProjection = self.PolarTransform(
897857
self,
898-
apply_theta_transforms=False,
899858
scale_transform=self.transScale
900859
)
901860
# Add dependency on rorigin.

lib/matplotlib/projections/polar.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class PolarTransform(mtransforms.Transform):
1818
axis: PolarAxes | None = ...,
1919
use_rmin: bool = ...,
2020
*,
21-
apply_theta_transforms: bool = ...,
2221
scale_transform: mtransforms.Transform | None = ...,
2322
) -> None: ...
2423
def inverted(self) -> InvertedPolarTransform: ...
@@ -35,8 +34,6 @@ class InvertedPolarTransform(mtransforms.Transform):
3534
self,
3635
axis: PolarAxes | None = ...,
3736
use_rmin: bool = ...,
38-
*,
39-
apply_theta_transforms: bool = ...,
4037
) -> None: ...
4138
def inverted(self) -> PolarTransform: ...
4239

lib/matplotlib/tests/test_transforms.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,7 @@ def test_str_transform():
891891
Affine2D().scale(1.0))),
892892
PolarTransform(
893893
PolarAxes(0.125,0.1;0.775x0.8),
894-
use_rmin=True,
895-
apply_theta_transforms=False)),
894+
use_rmin=True)),
896895
CompositeGenericTransform(
897896
CompositeGenericTransform(
898897
PolarAffine(

lib/matplotlib/text.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,9 +1553,7 @@ def _get_xy_transform(self, renderer, coords):
15531553
return self.axes.transData
15541554
elif coords == 'polar':
15551555
from matplotlib.projections import PolarAxes
1556-
tr = PolarAxes.PolarTransform(apply_theta_transforms=False)
1557-
trans = tr + self.axes.transData
1558-
return trans
1556+
return PolarAxes.PolarTransform() + self.axes.transData
15591557

15601558
try:
15611559
bbox_name, unit = coords.split()

lib/mpl_toolkits/axisartist/tests/test_floating_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_curvelinear3():
2626
fig = plt.figure(figsize=(5, 5))
2727

2828
tr = (mtransforms.Affine2D().scale(np.pi / 180, 1) +
29-
mprojections.PolarAxes.PolarTransform(apply_theta_transforms=False))
29+
mprojections.PolarAxes.PolarTransform())
3030
grid_helper = GridHelperCurveLinear(
3131
tr,
3232
extremes=(0, 360, 10, 3),
@@ -75,7 +75,7 @@ def test_curvelinear4():
7575
fig = plt.figure(figsize=(5, 5))
7676

7777
tr = (mtransforms.Affine2D().scale(np.pi / 180, 1) +
78-
mprojections.PolarAxes.PolarTransform(apply_theta_transforms=False))
78+
mprojections.PolarAxes.PolarTransform())
7979
grid_helper = GridHelperCurveLinear(
8080
tr,
8181
extremes=(120, 30, 10, 0),

lib/mpl_toolkits/axisartist/tests/test_grid_helper_curvelinear.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ def test_polar_box():
8282

8383
# PolarAxes.PolarTransform takes radian. However, we want our coordinate
8484
# system in degree
85-
tr = (Affine2D().scale(np.pi / 180., 1.) +
86-
PolarAxes.PolarTransform(apply_theta_transforms=False))
85+
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform()
8786

8887
# polar projection, which involves cycle, and also has limits in
8988
# its coordinates, needs a special method to find the extremes
@@ -145,8 +144,7 @@ def test_axis_direction():
145144

146145
# PolarAxes.PolarTransform takes radian. However, we want our coordinate
147146
# system in degree
148-
tr = (Affine2D().scale(np.pi / 180., 1.) +
149-
PolarAxes.PolarTransform(apply_theta_transforms=False))
147+
tr = Affine2D().scale(np.pi / 180., 1.) + PolarAxes.PolarTransform()
150148

151149
# polar projection, which involves cycle, and also has limits in
152150
# its coordinates, needs a special method to find the extremes

0 commit comments

Comments
 (0)