Skip to content

Shorten some inset_locator docstrings. #21866

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 2 commits into from
Dec 5, 2021
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
21 changes: 9 additions & 12 deletions examples/subplots_axes_and_figures/axes_zoom_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,14 @@ def zoom_effect02(ax1, ax2, **kwargs):
return c1, c2, bbox_patch1, bbox_patch2, p


plt.figure(figsize=(5, 5))
ax1 = plt.subplot(221)
ax2 = plt.subplot(212)
ax2.set_xlim(0, 1)
ax2.set_xlim(0, 5)
zoom_effect01(ax1, ax2, 0.2, 0.8)


ax1 = plt.subplot(222)
ax1.set_xlim(2, 3)
ax2.set_xlim(0, 5)
zoom_effect02(ax1, ax2)
axs = plt.figure().subplot_mosaic([
["zoom1", "zoom2"],
["main", "main"],
])

axs["main"].set(xlim=(0, 5))
zoom_effect01(axs["zoom1"], axs["main"], 0.2, 0.8)
axs["zoom2"].set(xlim=(2, 3))
zoom_effect02(axs["zoom2"], axs["main"])

plt.show()
81 changes: 12 additions & 69 deletions lib/mpl_toolkits/axes_grid1/inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,8 @@ class BboxConnector(Patch):
@staticmethod
def get_bbox_edge_pos(bbox, loc):
"""
Helper function to obtain the location of a corner of a bbox

Parameters
----------
bbox : `matplotlib.transforms.Bbox`

loc : {1, 2, 3, 4}
Corner of *bbox*. Valid values are::

'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4

Returns
-------
x, y : float
Coordinates of the corner specified by *loc*.
Return the ``(x, y)`` coordinates of corner *loc* of *bbox*; parameters
behave as documented for the `.BboxConnector` constructor.
"""
x0, y0, x1, y1 = bbox.extents
if loc == 1:
Expand All @@ -200,35 +184,9 @@ def get_bbox_edge_pos(bbox, loc):
@staticmethod
def connect_bbox(bbox1, bbox2, loc1, loc2=None):
"""
Helper function to obtain a Path from one bbox to another.

Parameters
----------
bbox1, bbox2 : `matplotlib.transforms.Bbox`
Bounding boxes to connect.

loc1 : {1, 2, 3, 4}
Corner of *bbox1* to use. Valid values are::

'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4

loc2 : {1, 2, 3, 4}, optional
Corner of *bbox2* to use. If None, defaults to *loc1*.
Valid values are::

'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4

Returns
-------
path : `matplotlib.path.Path`
A line segment from the *loc1* corner of *bbox1* to the *loc2*
corner of *bbox2*.
Construct a `.Path` connecting corner *loc1* of *bbox1* to corner
*loc2* of *bbox2*, where parameters behave as documented as for the
`.BboxConnector` constructor.
"""
if isinstance(bbox1, Rectangle):
bbox1 = TransformedBbox(Bbox.unit(), bbox1.get_transform())
Expand All @@ -250,22 +208,15 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
bbox1, bbox2 : `matplotlib.transforms.Bbox`
Bounding boxes to connect.

loc1 : {1, 2, 3, 4}
Corner of *bbox1* to draw the line. Valid values are::
loc1, loc2 : {1, 2, 3, 4}
Corner of *bbox1* and *bbox2* to draw the line. Valid values are::

'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4

loc2 : {1, 2, 3, 4}, optional
Corner of *bbox2* to draw the line. If None, defaults to *loc1*.
Valid values are::

'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4
*loc2* is optional and defaults to *loc1*.

**kwargs
Patch properties for the line drawn. Valid arguments include:
Expand Down Expand Up @@ -308,18 +259,10 @@ def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
bbox1, bbox2 : `matplotlib.transforms.Bbox`
Bounding boxes to connect.

loc1a, loc2a : {1, 2, 3, 4}
Corners of *bbox1* and *bbox2* to draw the first line.
Valid values are::

'upper right' : 1,
'upper left' : 2,
'lower left' : 3,
'lower right' : 4

loc1b, loc2b : {1, 2, 3, 4}
Corners of *bbox1* and *bbox2* to draw the second line.
Valid values are::
loc1a, loc2a, loc1b, loc2b : {1, 2, 3, 4}
The first line connects corners *loc1a* of *bbox1* and *loc2a* of
*bbox2*; the second line connects corners *loc1b* of *bbox1* and
*loc2b* of *bbox2*. Valid values are::

'upper right' : 1,
'upper left' : 2,
Expand Down