Skip to content

Commit 46e4958

Browse files
committed
Add some Eigen helpers for PolarTransform
1 parent 966b0d2 commit 46e4958

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

lib/matplotlib/projections/polar.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,7 @@ def set_theta_offset(self, offset):
10731073
"""
10741074
Set the offset for the location of 0 in radians.
10751075
"""
1076-
mtx = self._theta_offset.get_matrix()
1077-
mtx[0, 2] = offset
1076+
self._theta_offset._mtx._set_translatex(offset)
10781077
self._theta_offset.invalidate()
10791078

10801079
def get_theta_offset(self):
@@ -1119,11 +1118,10 @@ def set_theta_direction(self, direction):
11191118
counterclockwise, anticlockwise, 1:
11201119
Theta increases in the counterclockwise direction
11211120
"""
1122-
mtx = self._direction.get_matrix()
11231121
if direction in ('clockwise', -1):
1124-
mtx[0, 0] = -1
1122+
self._direction._mtx._set_scalex(-1)
11251123
elif direction in ('counterclockwise', 'anticlockwise', 1):
1126-
mtx[0, 0] = 1
1124+
self._direction._mtx._set_scalex(1)
11271125
else:
11281126
_api.check_in_list(
11291127
[-1, 1, 'clockwise', 'counterclockwise', 'anticlockwise'],

src/_eigen.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,13 @@ PYBIND11_MODULE(_eigen, m) {
132132
return result.attr("transpose")();
133133
}
134134
)
135+
136+
// Helpers for PolarTransform.
137+
.def("_set_scalex", [](Eigen::Affine2d& self, double scale) {
138+
self(0, 0) = scale;
139+
})
140+
.def("_set_translatex", [](Eigen::Affine2d& self, double offset) {
141+
self(0, 2) = offset;
142+
})
135143
;
136144
}

0 commit comments

Comments
 (0)