diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 7b5fca90fce8..44bc3d279a27 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -568,13 +568,15 @@ def _get_text_path_transform(self, x, y, s, prop, angle, ismath): angle = np.deg2rad(angle) if self.flipy(): width, height = self.get_canvas_width_height() - transform = Affine2D().scale(fontsize / text2path.FONT_SCALE, - fontsize / text2path.FONT_SCALE) - transform = transform.rotate(angle).translate(x, height - y) + transform = (Affine2D() + .scale(fontsize / text2path.FONT_SCALE) + .rotate(angle) + .translate(x, height - y)) else: - transform = Affine2D().scale(fontsize / text2path.FONT_SCALE, - fontsize / text2path.FONT_SCALE) - transform = transform.rotate(angle).translate(x, y) + transform = (Affine2D() + .scale(fontsize / text2path.FONT_SCALE) + .rotate(angle) + .translate(x, y)) return path, transform diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 2896a2477ddd..e877e3bb7ced 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -354,7 +354,7 @@ def __init__(self, f'{figsize}') self.bbox_inches = Bbox.from_bounds(0, 0, *figsize) - self.dpi_scale_trans = Affine2D().scale(dpi, dpi) + self.dpi_scale_trans = Affine2D().scale(dpi) # do not use property as it will trigger self._dpi = dpi self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans) @@ -477,7 +477,7 @@ def _set_dpi(self, dpi, forward=True): Passed on to `~.Figure.set_size_inches` """ self._dpi = dpi - self.dpi_scale_trans.clear().scale(dpi, dpi) + self.dpi_scale_trans.clear().scale(dpi) w, h = self.get_size_inches() self.set_size_inches(w, h, forward=forward) self.callbacks.process('dpi_changed', self) @@ -2391,8 +2391,7 @@ def get_tightbbox(self, renderer, bbox_extra_artists=None): _bbox = Bbox.union(bb) - bbox_inches = TransformedBbox(_bbox, - Affine2D().scale(1. / self.dpi)) + bbox_inches = TransformedBbox(_bbox, Affine2D().scale(1 / self.dpi)) return bbox_inches diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 985e6cb91525..60f9dd7e74c6 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -335,10 +335,9 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0, + self.get_transform()) t = (t0 - + Affine2D().translate( - -clipped_bbox.x0, - -clipped_bbox.y0) - .scale(magnification, magnification)) + + (Affine2D() + .translate(-clipped_bbox.x0, -clipped_bbox.y0) + .scale(magnification))) # So that the image is aligned with the edge of the axes, we want to # round up the output width to the next integer. This also means diff --git a/lib/matplotlib/markers.py b/lib/matplotlib/markers.py index c3eec2fe4cee..8ec0e43ec449 100644 --- a/lib/matplotlib/markers.py +++ b/lib/matplotlib/markers.py @@ -453,7 +453,7 @@ def _set_point(self): [Path.MOVETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]) def _set_triangle(self, rot, skip): - self._transform = Affine2D().scale(0.5, 0.5).rotate_deg(rot) + self._transform = Affine2D().scale(0.5).rotate_deg(rot) self._snap_threshold = 5.0 fs = self.get_fillstyle() diff --git a/lib/matplotlib/offsetbox.py b/lib/matplotlib/offsetbox.py index 744ef48d40fb..cfa37e6198ab 100644 --- a/lib/matplotlib/offsetbox.py +++ b/lib/matplotlib/offsetbox.py @@ -763,7 +763,7 @@ def draw(self, renderer): dpi_cor = renderer.points_to_pixels(1.) self.dpi_transform.clear() - self.dpi_transform.scale(dpi_cor, dpi_cor) + self.dpi_transform.scale(dpi_cor) # At this point the DrawingArea has a transform # to the display space so the path created is diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py index 052c9eb50418..adc824a9e1b4 100644 --- a/lib/matplotlib/text.py +++ b/lib/matplotlib/text.py @@ -1729,7 +1729,7 @@ def __call__(self, renderer): raise RuntimeError("unknown type") sc = self._get_scale(renderer) - tr = Affine2D().scale(sc, sc).translate(x, y) + tr = Affine2D().scale(sc).translate(x, y) return tr @@ -1822,13 +1822,13 @@ def _get_xy_transform(self, renderer, s): if unit == "points": # dots per points dpp = self.figure.get_dpi() / 72. - tr = Affine2D().scale(dpp, dpp) + tr = Affine2D().scale(dpp) elif unit == "pixels": tr = Affine2D() elif unit == "fontsize": fontsize = self.get_size() dpp = fontsize * self.figure.get_dpi() / 72. - tr = Affine2D().scale(dpp, dpp) + tr = Affine2D().scale(dpp) elif unit == "fraction": w, h = bbox0.bounds[2:] tr = Affine2D().scale(w, h) diff --git a/lib/matplotlib/textpath.py b/lib/matplotlib/textpath.py index 3eb73326add9..5f52cd0b778b 100644 --- a/lib/matplotlib/textpath.py +++ b/lib/matplotlib/textpath.py @@ -482,9 +482,9 @@ def _revalidate_path(self): `~.FONT_SCALE`, and this path is rescaled to other size when necessary. """ if self._invalid or self._cached_vertices is None: - tr = Affine2D().scale( - self._size / text_to_path.FONT_SCALE, - self._size / text_to_path.FONT_SCALE).translate(*self._xy) + tr = (Affine2D() + .scale(self._size / text_to_path.FONT_SCALE) + .translate(*self._xy)) self._cached_vertices = tr.transform(self._vertices) self._invalid = False diff --git a/lib/mpl_toolkits/axisartist/axis_artist.py b/lib/mpl_toolkits/axisartist/axis_artist.py index b81340054e7f..b68e1f3124fe 100644 --- a/lib/mpl_toolkits/axisartist/axis_artist.py +++ b/lib/mpl_toolkits/axisartist/axis_artist.py @@ -268,7 +268,7 @@ def draw(self, renderer): gc.set_alpha(self._alpha) offset = renderer.points_to_pixels(size) - marker_scale = Affine2D().scale(offset, offset) + marker_scale = Affine2D().scale(offset) if self.get_tick_out(): add_angle = 180 @@ -279,7 +279,7 @@ def draw(self, renderer): marker_transform = marker_scale + marker_rotation for loc, angle in self.locs_angles: - marker_rotation.clear().rotate_deg(angle+add_angle) + marker_rotation.clear().rotate_deg(angle + add_angle) locs = path_trans.transform_non_affine(np.array([loc])) if self.axes and not self.axes.viewLim.contains(*locs[0]): continue @@ -1219,7 +1219,7 @@ def get_tightbbox(self, renderer): self._axis_artist_helper.update_lim(self.axes) dpi_cor = renderer.points_to_pixels(1.) - self.dpi_transform.clear().scale(dpi_cor, dpi_cor) + self.dpi_transform.clear().scale(dpi_cor) self._update_ticks(renderer) self._update_label(renderer) @@ -1248,7 +1248,7 @@ def draw(self, renderer): self._axis_artist_helper.update_lim(self.axes) dpi_cor = renderer.points_to_pixels(1.) - self.dpi_transform.clear().scale(dpi_cor, dpi_cor) + self.dpi_transform.clear().scale(dpi_cor) self._draw_ticks(renderer) self._draw_line(renderer)