Skip to content
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
6 changes: 6 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,9 @@ The *add_all* parameter of `.axes_grid1.axes_grid.Grid`,
`.axes_grid1.axes_grid.ImageGrid`, `.axes_grid1.axes_rgb.make_rgb_axes` and
`.axes_grid1.axes_rgb.RGBAxes` is deprecated. Axes are now always added to the
parent figure, though they can be later removed with ``ax.remove()``.

``BboxBase.inverse_transformed``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``.BboxBase.inverse_transformed`` is deprecated (call `.BboxBase.transformed`
on the `~.Transform.inverted()` transform instead).
5 changes: 3 additions & 2 deletions examples/pyplots/auto_subplots_adjust.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def on_draw(event):
bbox = label.get_window_extent()
# the figure transform goes from relative coords->pixels and we
# want the inverse of that
bboxi = bbox.inverse_transformed(fig.transFigure)
bboxi = bbox.transformed(fig.transFigure.inverted())
bboxes.append(bboxi)

# this is the bbox that bounds all the bboxes, again in relative
Expand Down Expand Up @@ -54,8 +54,9 @@ def on_draw(event):
import matplotlib
matplotlib.artist.Artist.get_window_extent
matplotlib.transforms.Bbox
matplotlib.transforms.Bbox.inverse_transformed
matplotlib.transforms.Bbox.transformed
matplotlib.transforms.Bbox.union
matplotlib.transforms.Transform.inverted
matplotlib.figure.Figure.subplots_adjust
matplotlib.figure.SubplotParams
matplotlib.backend_bases.FigureCanvasBase.mpl_connect
2 changes: 1 addition & 1 deletion lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def get_datalim(self, transData):
result = mpath.get_path_collection_extents(
transform.get_affine(), paths, self.get_transforms(),
offsets, transOffset.get_affine().frozen())
return result.inverse_transformed(transData)
return result.transformed(transData.inverted())
if not self._offsetsNone:
# this is for collections that have their paths (shapes)
# in physical, axes-relative, or figure-relative units
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ def get_text_bounds(self, renderer):
"""
Return the text bounds as *(x, y, width, height)* in table coordinates.
"""
bbox = self._text.get_window_extent(renderer)
bboxa = bbox.inverse_transformed(self.get_data_transform())
return bboxa.bounds
return (self._text.get_window_extent(renderer)
.transformed(self.get_data_transform().inverted())
.bounds)

def get_required_width(self, renderer):
"""Return the minimal required width for the cell."""
Expand Down Expand Up @@ -431,7 +431,7 @@ def _get_grid_bbox(self, renderer):
for (row, col), cell in self._cells.items()
if row >= 0 and col >= 0]
bbox = Bbox.union(boxes)
return bbox.inverse_transformed(self.get_transform())
return bbox.transformed(self.get_transform().inverted())

def contains(self, mouseevent):
# docstring inherited
Expand Down
7 changes: 4 additions & 3 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,12 @@ def test_multiline2():
renderer = fig.canvas.get_renderer()

def draw_box(ax, tt):
bb = tt.get_window_extent(renderer)
bbt = bb.inverse_transformed(ax.transAxes)
r = mpatches.Rectangle((0, 0), 1, 1, clip_on=False,
transform=ax.transAxes)
r.set_bounds(bbt.bounds)
r.set_bounds(
tt.get_window_extent(renderer)
.transformed(ax.transAxes.inverted())
.bounds)
ax.add_patch(r)

horal = 'left'
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ def transformed(self, transform):
[pts[0], [pts[0, 0], pts[1, 1]], [pts[1, 0], pts[0, 1]]]))
return Bbox([ll, [lr[0], ul[1]]])

@cbook.deprecated("3.3", alternative="transformed(transform.inverted())")
def inverse_transformed(self, transform):
"""
Construct a `Bbox` by statically transforming this one by the inverse
Expand Down