Skip to content

Commit

Permalink
FIX: renamed methods again
Browse files Browse the repository at this point in the history
  • Loading branch information
jklymak committed Jun 19, 2018
1 parent 8a7a7f7 commit 435db99
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions doc/api/axes_api.rst
Expand Up @@ -165,8 +165,8 @@ Text and Annotations
Axes.text
Axes.table
Axes.arrow
Axes.inset_axes_from_lbwh
Axes.indicate_inset_lbwh
Axes.inset_axes_from_bounds
Axes.indicate_inset_bounds
Axes.indicate_inset_zoom


Expand Down
4 changes: 2 additions & 2 deletions examples/subplots_axes_and_figures/zoom_inset_axes.py
Expand Up @@ -31,7 +31,7 @@ def get_demo_image():
origin="lower")

# inset axes....
axins = ax.inset_axes_from_lbwh([0.5, 0.5, 0.47, 0.47])
axins = ax.inset_axes_from_bounds([0.5, 0.5, 0.47, 0.47])
axins.imshow(Z2, extent=extent, interpolation="nearest",
origin="lower")
# sub region of the original image
Expand All @@ -55,6 +55,6 @@ def get_demo_image():
# The use of the following functions and methods is shown in this example:

import matplotlib
matplotlib.axes.Axes.inset_axes_from_lbwh
matplotlib.axes.Axes.inset_axes_from_bounds
matplotlib.axes.Axes.indicate_inset_zoom
matplotlib.axes.Axes.imshow
38 changes: 20 additions & 18 deletions lib/matplotlib/axes/_axes.py
Expand Up @@ -80,7 +80,8 @@ def _plot_args_replacer(args, data):

def _make_inset_locator(rect, trans, parent):
"""
Helper function to locate inset axes, used in `.Axes.inset_axes_from_lbwh`.
Helper function to locate inset axes, used in
`.Axes.inset_axes_from_bounds`.
A locator gets used in `Axes.set_aspect` to override the default
locations... It is a function that takes an axes object and
Expand Down Expand Up @@ -411,7 +412,7 @@ def legend(self, *args, **kwargs):
def _remove_legend(self, legend):
self.legend_ = None

def inset_axes_from_lbwh(self, lbwh, *, transform=None, zorder=5,
def inset_axes_from_bounds(self, bounds, *, transform=None, zorder=5,
**kwargs):
"""
Add a child inset axes to this existing axes.
Expand All @@ -424,7 +425,7 @@ def inset_axes_from_lbwh(self, lbwh, *, transform=None, zorder=5,
Parameters
----------
lbwh : [x0, y0, width, height]
bounds : [x0, y0, width, height]
Lower-left corner of inset axes, and its width and height.
transform : `.Transform`
Expand Down Expand Up @@ -454,17 +455,17 @@ def inset_axes_from_lbwh(self, lbwh, *, transform=None, zorder=5,
fig, ax = plt.suplots()
ax.plot(range(10))
axin1 = ax.inset_axes_from_lbwh([0.8, 0.1, 0.15, 0.15])
axin2 = ax.inset_axes_from_lbwh(
axin1 = ax.inset_axes_from_bounds([0.8, 0.1, 0.15, 0.15])
axin2 = ax.inset_axes_from_bounds(
[5, 7, 2.3, 2.3], transform=ax.transData)
"""
if transform is None:
transform = self.transAxes
label = kwargs.pop('label', 'inset_axes_from_lbwh')
label = kwargs.pop('label', 'inset_axes_from_bounds')

# This puts the rectangle into figure-relative coordinates.
inset_locator = _make_inset_locator(lbwh, transform, self)
inset_locator = _make_inset_locator(bounds, transform, self)
bb = inset_locator(None, None)

inset_ax = Axes(self.figure, bb.bounds, zorder=zorder,
Expand All @@ -478,13 +479,14 @@ def inset_axes_from_lbwh(self, lbwh, *, transform=None, zorder=5,

return inset_ax

def indicate_inset_lbwh(self, lbwh, inset_ax=None, *, transform=None,
def indicate_inset_bounds(self, bounds, inset_ax=None, *, transform=None,
facecolor='none', edgecolor='0.5', alpha=0.5,
zorder=4.99, **kwargs):
"""
Add an inset indicator to the axes. This is a rectangle on the plot
at the position indicated by *lbwh* that optionally has lines that
connect the rectangle to an inset axes (`.Axes.inset_axes_from_lbwh`).
at the position indicated by *bounds* that optionally has lines that
connect the rectangle to an inset axes
(`.Axes.inset_axes_from_bounds`).
Warnings
--------
Expand All @@ -495,7 +497,7 @@ def indicate_inset_lbwh(self, lbwh, inset_ax=None, *, transform=None,
Parameters
----------
lbwh : [x0, y0, width, height]
bounds : [x0, y0, width, height]
Lower-left corner of rectangle to be marked, and its width
and height.
Expand Down Expand Up @@ -545,10 +547,10 @@ def indicate_inset_lbwh(self, lbwh, inset_ax=None, *, transform=None,

if transform is None:
transform = self.transData
label = kwargs.pop('label', 'indicate_inset_lbwh')
label = kwargs.pop('label', 'indicate_inset_bounds')

xy = (lbwh[0], lbwh[1])
rectpatch = mpatches.Rectangle(xy, lbwh[2], lbwh[3],
xy = (bounds[0], bounds[1])
rectpatch = mpatches.Rectangle(xy, bounds[2], bounds[3],
facecolor=facecolor, edgecolor=edgecolor, alpha=alpha,
zorder=zorder, label=label, transform=transform, **kwargs)
self.add_patch(rectpatch)
Expand All @@ -559,8 +561,8 @@ def indicate_inset_lbwh(self, lbwh, inset_ax=None, *, transform=None,
pos = inset_ax.get_position() # this is in fig-fraction.
coordsA = 'axes fraction'
connects = []
xr = [lbwh[0], lbwh[0]+lbwh[2]]
yr = [lbwh[1], lbwh[1]+lbwh[3]]
xr = [bounds[0], bounds[0]+bounds[2]]
yr = [bounds[1], bounds[1]+bounds[3]]
for xc in range(2):
for yc in range(2):
xyA = (xc, yc)
Expand All @@ -574,7 +576,7 @@ def indicate_inset_lbwh(self, lbwh, inset_ax=None, *, transform=None,
pos = inset_ax.get_position()
bboxins = pos.transformed(self.figure.transFigure)
rectbbox = mtransforms.Bbox.from_bounds(
*lbwh).transformed(transform)
*bounds).transformed(transform)
if rectbbox.x0 < bboxins.x0:
sig = 1
else:
Expand Down Expand Up @@ -626,7 +628,7 @@ def indicate_inset_zoom(self, inset_ax, **kwargs):
xlim = inset_ax.get_xlim()
ylim = inset_ax.get_ylim()
rect = [xlim[0], ylim[0], xlim[1] - xlim[0], ylim[1] - ylim[0]]
rectpatch, connects = self.indicate_inset_lbwh(
rectpatch, connects = self.indicate_inset_bounds(
rect, inset_ax, **kwargs)

return rectpatch, connects
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -5743,8 +5743,8 @@ def test_zoom_inset():
ax.apply_aspect()
# we need to apply_aspect to make the drawing below work.

# Make the inset_axes_from_lbwh... Position axes co-ordinates...
axin1 = ax.inset_axes_from_lbwh([0.7, 0.7, 0.35, 0.35])
# Make the inset_axes_from_bounds... Position axes co-ordinates...
axin1 = ax.inset_axes_from_bounds([0.7, 0.7, 0.35, 0.35])
# redraw the data in the inset axes...
axin1.pcolormesh(x, y, z)
axin1.set_xlim([1.5, 2.15])
Expand Down

0 comments on commit 435db99

Please sign in to comment.