Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 782ed8a

Browse files
committed
Move class docstrings in axes_grid1.inset_locator to constructors
Fixes Py2k compatibility
1 parent 8c87a02 commit 782ed8a

File tree

1 file changed

+99
-100
lines changed

1 file changed

+99
-100
lines changed

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 99 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,39 @@
1515
from .parasite_axes import HostAxes
1616

1717

18-
@docstring.dedent_interpd
1918
class InsetPosition(object):
20-
"""
21-
An object for positioning an inset axes.
19+
@docstring.dedent_interpd
20+
def __init__(self, parent, lbwh):
21+
"""
22+
An object for positioning an inset axes.
2223
23-
This is created by specifying the normalized coordinates in the axes,
24-
instead of the figure.
24+
This is created by specifying the normalized coordinates in the axes,
25+
instead of the figure.
2526
26-
Parameters
27-
----------
28-
parent : `matplotlib.axes.Axes`
29-
Axes to use for normalizing coordinates.
30-
31-
lbwh : iterable of four floats
32-
The left edge, bottom edge, width, and height of the inset axes, in
33-
units of the normalized coordinate of the *parent* axes.
34-
35-
See Also
36-
--------
37-
:meth:`matplotlib.axes.Axes.set_axes_locator`
38-
39-
Examples
40-
--------
41-
The following bounds the inset axes to a box with 20%% of the parent
42-
axes's height and 40%% of the width. The size of the axes specified
43-
([0, 0, 1, 1]) ensures that the axes completely fills the bounding box:
44-
45-
>>> parent_axes = plt.gca()
46-
>>> ax_ins = plt.axes([0, 0, 1, 1])
47-
>>> ip = InsetPosition(ax, [0.5, 0.1, 0.4, 0.2])
48-
>>> ax_ins.set_axes_locator(ip)
49-
"""
50-
def __init__(self, parent, lbwh):
27+
Parameters
28+
----------
29+
parent : `matplotlib.axes.Axes`
30+
Axes to use for normalizing coordinates.
31+
32+
lbwh : iterable of four floats
33+
The left edge, bottom edge, width, and height of the inset axes, in
34+
units of the normalized coordinate of the *parent* axes.
35+
36+
See Also
37+
--------
38+
:meth:`matplotlib.axes.Axes.set_axes_locator`
39+
40+
Examples
41+
--------
42+
The following bounds the inset axes to a box with 20%% of the parent
43+
axes's height and 40%% of the width. The size of the axes specified
44+
([0, 0, 1, 1]) ensures that the axes completely fills the bounding box:
45+
46+
>>> parent_axes = plt.gca()
47+
>>> ax_ins = plt.axes([0, 0, 1, 1])
48+
>>> ip = InsetPosition(ax, [0.5, 0.1, 0.4, 0.2])
49+
>>> ax_ins.set_axes_locator(ip)
50+
"""
5151
self.parent = parent
5252
self.lbwh = lbwh
5353

@@ -146,20 +146,20 @@ def get_extent(self, renderer):
146146
return w*self.zoom+2*pad, h*self.zoom+2*pad, xd+pad, yd+pad
147147

148148

149-
@docstring.dedent_interpd
150149
class BboxPatch(Patch):
151-
"""
152-
Patch showing the shape bounded by a Bbox.
150+
@docstring.dedent_interpd
151+
def __init__(self, bbox, **kwargs):
152+
"""
153+
Patch showing the shape bounded by a Bbox.
153154
154-
Parameters
155-
----------
156-
bbox : `matplotlib.transforms.Bbox`
157-
Bbox to use for the extents of this patch.
155+
Parameters
156+
----------
157+
bbox : `matplotlib.transforms.Bbox`
158+
Bbox to use for the extents of this patch.
158159
159-
The kwargs are Patch properties:
160-
%(Patch)s
161-
"""
162-
def __init__(self, bbox, **kwargs):
160+
The kwargs are Patch properties:
161+
%(Patch)s
162+
"""
163163
if "transform" in kwargs:
164164
raise ValueError("transform should not be set")
165165

@@ -188,37 +188,7 @@ def get_path(self):
188188
get_path.__doc__ = Patch.get_path.__doc__
189189

190190

191-
@docstring.dedent_interpd
192191
class BboxConnector(Patch):
193-
"""
194-
Connect two bboxes with a straight line.
195-
196-
Parameters
197-
----------
198-
bbox1, bbox2 : `matplotlib.transforms.Bbox`
199-
Bounding boxes to connect.
200-
201-
loc1 : {1, 2, 3, 4}
202-
Corner of *bbox1* to draw the line. Valid values are::
203-
204-
'upper right' : 1,
205-
'upper left' : 2,
206-
'lower left' : 3,
207-
'lower right' : 4
208-
209-
loc2 : {1, 2, 3, 4}, optional
210-
Corner of *bbox2* to draw the line. If None, defaults to *loc1*.
211-
Valid values are::
212-
213-
'upper right' : 1,
214-
'upper left' : 2,
215-
'lower left' : 3,
216-
'lower right' : 4
217-
218-
The kwargs are Patch properties for the line drawn:
219-
%(Patch)s
220-
"""
221-
222192
@staticmethod
223193
def get_bbox_edge_pos(bbox, loc):
224194
"""
@@ -305,7 +275,36 @@ def connect_bbox(bbox1, bbox2, loc1, loc2=None):
305275

306276
return Path(verts, codes)
307277

278+
@docstring.dedent_interpd
308279
def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
280+
"""
281+
Connect two bboxes with a straight line.
282+
283+
Parameters
284+
----------
285+
bbox1, bbox2 : `matplotlib.transforms.Bbox`
286+
Bounding boxes to connect.
287+
288+
loc1 : {1, 2, 3, 4}
289+
Corner of *bbox1* to draw the line. Valid values are::
290+
291+
'upper right' : 1,
292+
'upper left' : 2,
293+
'lower left' : 3,
294+
'lower right' : 4
295+
296+
loc2 : {1, 2, 3, 4}, optional
297+
Corner of *bbox2* to draw the line. If None, defaults to *loc1*.
298+
Valid values are::
299+
300+
'upper right' : 1,
301+
'upper left' : 2,
302+
'lower left' : 3,
303+
'lower right' : 4
304+
305+
The kwargs are Patch properties for the line drawn:
306+
%(Patch)s
307+
"""
309308
if "transform" in kwargs:
310309
raise ValueError("transform should not be set")
311310

@@ -322,43 +321,43 @@ def get_path(self):
322321
get_path.__doc__ = Patch.get_path.__doc__
323322

324323

325-
@docstring.dedent_interpd
326324
class BboxConnectorPatch(BboxConnector):
327-
"""
328-
Connect two bboxes with a quadrilateral.
325+
@docstring.dedent_interpd
326+
def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
327+
"""
328+
Connect two bboxes with a quadrilateral.
329329
330-
The quadrilateral is specified by two lines that start and end at corners
331-
of the bboxes. The four sides of the quadrilateral are defined by the two
332-
lines given, the line between the two corners specified in *bbox1* and the
333-
line between the two corners specified in *bbox2*.
330+
The quadrilateral is specified by two lines that start and end at corners
331+
of the bboxes. The four sides of the quadrilateral are defined by the two
332+
lines given, the line between the two corners specified in *bbox1* and the
333+
line between the two corners specified in *bbox2*.
334334
335-
Parameters
336-
----------
337-
bbox1, bbox2 : `matplotlib.transforms.Bbox`
338-
Bounding boxes to connect.
335+
Parameters
336+
----------
337+
bbox1, bbox2 : `matplotlib.transforms.Bbox`
338+
Bounding boxes to connect.
339339
340-
loc1a, loc2a : {1, 2, 3, 4}
341-
Corners of *bbox1* and *bbox2* to draw the first line.
342-
Valid values are::
340+
loc1a, loc2a : {1, 2, 3, 4}
341+
Corners of *bbox1* and *bbox2* to draw the first line.
342+
Valid values are::
343343
344-
'upper right' : 1,
345-
'upper left' : 2,
346-
'lower left' : 3,
347-
'lower right' : 4
344+
'upper right' : 1,
345+
'upper left' : 2,
346+
'lower left' : 3,
347+
'lower right' : 4
348348
349-
loc1b, loc2b : {1, 2, 3, 4}
350-
Corners of *bbox1* and *bbox2* to draw the second line.
351-
Valid values are::
349+
loc1b, loc2b : {1, 2, 3, 4}
350+
Corners of *bbox1* and *bbox2* to draw the second line.
351+
Valid values are::
352352
353-
'upper right' : 1,
354-
'upper left' : 2,
355-
'lower left' : 3,
356-
'lower right' : 4
353+
'upper right' : 1,
354+
'upper left' : 2,
355+
'lower left' : 3,
356+
'lower right' : 4
357357
358-
The kwargs are Patch properties for the line drawn:
359-
%(Patch)s
360-
"""
361-
def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
358+
The kwargs are Patch properties for the line drawn:
359+
%(Patch)s
360+
"""
362361
if "transform" in kwargs:
363362
raise ValueError("transform should not be set")
364363
BboxConnector.__init__(self, bbox1, bbox2, loc1a, loc2a, **kwargs)

0 commit comments

Comments
 (0)