diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 06243a674cb8..b7bdac81802c 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -501,8 +501,7 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, # Subset the input image to only the part that will be # displayed - subset = TransformedBbox( - clip_bbox, t0.frozen().inverted()).frozen() + subset = TransformedBbox(clip_bbox, t0.inverted()).frozen() output = output[ int(max(subset.ymin, 0)): int(min(subset.ymax + 1, output.shape[0])), diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index 85dcc8c89d83..17e791a4499f 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -1638,11 +1638,10 @@ def iter_circle_intersect_on_line_seg(x0, y0, x1, y1): yield x, y # Transforms the axes box_path so that it is relative to the unit - # circle in the same way that it is relative to the desired - # ellipse. + # circle in the same way that it is relative to the desired ellipse. box_path = Path.unit_rectangle() - box_path_transform = transforms.BboxTransformTo(self.axes.bbox) + \ - self.get_transform().inverted() + box_path_transform = (transforms.BboxTransformTo(self.axes.bbox) + - self.get_transform()) box_path = box_path.transformed(box_path_transform) thetas = set() @@ -4146,10 +4145,8 @@ def get_path(self): in display coordinates. """ _path, fillable = self.get_path_in_displaycoord() - if np.iterable(fillable): _path = concatenate_paths(_path) - return self.get_transform().inverted().transform_path(_path) def get_path_in_displaycoord(self): diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index 63263920676b..55de4172849a 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -96,8 +96,6 @@ def get_tick_iterators(self, axes): # c, angle, l is position, tick angle, and label return iter_major, iter_minor - - """ class _Base: @@ -138,7 +136,7 @@ def __init__(self, loc, nth_coord=None): _verts = np.array([[0., 0.], [1., 1.]]) - fixed_coord = 1-nth_coord + fixed_coord = 1 - nth_coord _verts[:, fixed_coord] = self.passthru_pt[fixed_coord] # axis line in transAxes @@ -166,21 +164,16 @@ def get_axislabel_pos_angle(self, axes): get_label_transform() returns a transform of (transAxes+offset) """ - loc = self._loc - pos, angle_tangent = dict(left=((0., 0.5), 90), - right=((1., 0.5), 90), - bottom=((0.5, 0.), 0), - top=((0.5, 1.), 0))[loc] - - return pos, angle_tangent + return dict(left=((0., 0.5), 90), # (position, angle_tangent) + right=((1., 0.5), 90), + bottom=((0.5, 0.), 0), + top=((0.5, 1.), 0))[self._loc] # TICK def get_tick_transform(self, axes): - trans_tick = [axes.get_xaxis_transform(), - axes.get_yaxis_transform()][self.nth_coord] - - return trans_tick + return [axes.get_xaxis_transform(), + axes.get_yaxis_transform()][self.nth_coord] class Floating(_Base): @@ -229,9 +222,7 @@ def get_tick_iterators(self, axes): minorLocs = minor.locator() minorLabels = minor.formatter.format_ticks(minorLocs) - trans_tick = self.get_tick_transform(axes) - - tr2ax = trans_tick + axes.transAxes.inverted() + tick_to_axes = self.get_tick_transform(axes) - axes.transAxes def _f(locs, labels): for x, l in zip(locs, labels): @@ -240,7 +231,7 @@ def _f(locs, labels): c[self.nth_coord] = x # check if the tick point is inside axes - c2 = tr2ax.transform(c) + c2 = tick_to_axes.transform(c) if (0 - self.delta1 <= c2[self.nth_coord] <= 1 + self.delta2): @@ -260,8 +251,8 @@ def get_line(self, axes): [1., 1.]]) fixed_coord = 1 - self.nth_coord - p = (axes.transData + axes.transAxes.inverted()).transform( - [self._value, self._value]) + data_to_axes = axes.transData - axes.transAxes + p = data_to_axes.transform([self._value, self._value]) _verts[:, fixed_coord] = p[fixed_coord] return Path(_verts) @@ -278,42 +269,27 @@ def get_axislabel_pos_angle(self, axes): get_label_transform() returns a transform of (transAxes+offset) """ - if self.nth_coord == 0: - angle = 0 - else: - angle = 90 - + angle = [0, 90][self.nth_coord] _verts = [0.5, 0.5] - - fixed_coord = 1-self.nth_coord - p = (axes.transData + axes.transAxes.inverted()).transform( - [self._value, self._value]) + fixed_coord = 1 - self.nth_coord + data_to_axes = axes.transData - axes.transAxes + p = data_to_axes.transform([self._value, self._value]) _verts[fixed_coord] = p[fixed_coord] - if not (0. <= _verts[fixed_coord] <= 1.): - return None, None - else: + if 0 <= _verts[fixed_coord] <= 1: return _verts, angle + else: + return None, None def get_tick_transform(self, axes): return axes.transData def get_tick_iterators(self, axes): """tick_loc, tick_angle, tick_label""" - - loc = self._axis_direction - - if loc in ["bottom", "top"]: - angle_normal, angle_tangent = 90, 0 - else: - angle_normal, angle_tangent = 0, 90 - if self.nth_coord == 0: angle_normal, angle_tangent = 90, 0 else: angle_normal, angle_tangent = 0, 90 - # angle = 90 - 90 * self.nth_coord - major = self.axis.major majorLocs = major.locator() majorLabels = major.formatter.format_ticks(majorLocs) @@ -322,14 +298,13 @@ def get_tick_iterators(self, axes): minorLocs = minor.locator() minorLabels = minor.formatter.format_ticks(minorLocs) - tr2ax = axes.transData + axes.transAxes.inverted() + data_to_axes = axes.transData - axes.transAxes def _f(locs, labels): for x, l in zip(locs, labels): - c = [self._value, self._value] c[self.nth_coord] = x - c1, c2 = tr2ax.transform(c) + c1, c2 = data_to_axes.transform(c) if (0 <= c1 <= 1 and 0 <= c2 <= 1 and 0 - self.delta1 <= [c1, c2][self.nth_coord] diff --git a/lib/mpl_toolkits/axisartist/floating_axes.py b/lib/mpl_toolkits/axisartist/floating_axes.py index 193b0b44dcf7..49ac68410bac 100644 --- a/lib/mpl_toolkits/axisartist/floating_axes.py +++ b/lib/mpl_toolkits/axisartist/floating_axes.py @@ -123,10 +123,9 @@ def f1(): mm = (yy1b - yy1a == 0) & (xx1b - xx1a == 0) # mask not defined dd dd[mm] = dd2[mm] + np.pi / 2 - trans_tick = self.get_tick_transform(axes) - tr2ax = trans_tick + axes.transAxes.inverted() + tick_to_axes = self.get_tick_transform(axes) - axes.transAxes for x, y, d, d2, lab in zip(xx1, yy1, dd, dd2, labels): - c2 = tr2ax.transform((x, y)) + c2 = tick_to_axes.transform((x, y)) delta = 0.00001 if 0-delta <= c2[0] <= 1+delta and 0-delta <= c2[1] <= 1+delta: d1, d2 = np.rad2deg([d, d2]) diff --git a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py index c3ff829556a6..93336b8d648b 100644 --- a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py @@ -161,8 +161,8 @@ def get_axislabel_pos_angle(self, axes): grid_finder = self.grid_helper.grid_finder (xx1,), (yy1,) = grid_finder.transform_xy([xx0], [yy0]) - trans_passingthrough_point = axes.transData + axes.transAxes.inverted() - p = trans_passingthrough_point.transform([xx1, yy1]) + data_to_axes = axes.transData - axes.transAxes + p = data_to_axes.transform([xx1, yy1]) if 0 <= p[0] <= 1 and 0 <= p[1] <= 1: xx1c, yy1c = axes.transData.transform([xx1, yy1]) @@ -253,10 +253,9 @@ def f1(): mm = (yy1b == yy1a) & (xx1b == xx1a) # mask where dd not defined dd[mm] = dd2[mm] + np.pi / 2 - trans_tick = self.get_tick_transform(axes) - tr2ax = trans_tick + axes.transAxes.inverted() + tick_to_axes = self.get_tick_transform(axes) - axes.transAxes for x, y, d, d2, lab in zip(xx1, yy1, dd, dd2, labels): - c2 = tr2ax.transform((x, y)) + c2 = tick_to_axes.transform((x, y)) delta = 0.00001 if 0-delta <= c2[0] <= 1+delta and 0-delta <= c2[1] <= 1+delta: d1, d2 = np.rad2deg([d, d2])