Skip to content

Replace Affine2D().scale(x, x) by Affine2D().scale(x). #14745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions lib/matplotlib/textpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions lib/mpl_toolkits/axisartist/axis_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down