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

Skip to content

Add documentation for mpl_toolkits.axes_grid1.inset_locator #4864

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 13 commits into from
Dec 16, 2015
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move class docstrings in axes_grid1.inset_locator to constructors
Fixes Py2k compatibility
  • Loading branch information
sargas committed Nov 15, 2015
commit a55250f42f5fc01ff1de20d8fa6eec49caaa9179
199 changes: 99 additions & 100 deletions lib/mpl_toolkits/axes_grid1/inset_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,39 @@
from .parasite_axes import HostAxes


@docstring.dedent_interpd
class InsetPosition(object):
"""
An object for positioning an inset axes.
@docstring.dedent_interpd
def __init__(self, parent, lbwh):
"""
An object for positioning an inset axes.

This is created by specifying the normalized coordinates in the axes,
instead of the figure.
This is created by specifying the normalized coordinates in the axes,
instead of the figure.

Parameters
----------
parent : `matplotlib.axes.Axes`
Axes to use for normalizing coordinates.

lbwh : iterable of four floats
The left edge, bottom edge, width, and height of the inset axes, in
units of the normalized coordinate of the *parent* axes.

See Also
--------
:meth:`matplotlib.axes.Axes.set_axes_locator`

Examples
--------
The following bounds the inset axes to a box with 20%% of the parent
axes's height and 40%% of the width. The size of the axes specified
([0, 0, 1, 1]) ensures that the axes completely fills the bounding box:

>>> parent_axes = plt.gca()
>>> ax_ins = plt.axes([0, 0, 1, 1])
>>> ip = InsetPosition(ax, [0.5, 0.1, 0.4, 0.2])
>>> ax_ins.set_axes_locator(ip)
"""
def __init__(self, parent, lbwh):
Parameters
----------
parent : `matplotlib.axes.Axes`
Axes to use for normalizing coordinates.

lbwh : iterable of four floats
The left edge, bottom edge, width, and height of the inset axes, in
units of the normalized coordinate of the *parent* axes.

See Also
--------
:meth:`matplotlib.axes.Axes.set_axes_locator`

Examples
--------
The following bounds the inset axes to a box with 20%% of the parent
axes's height and 40%% of the width. The size of the axes specified
([0, 0, 1, 1]) ensures that the axes completely fills the bounding box:

>>> parent_axes = plt.gca()
>>> ax_ins = plt.axes([0, 0, 1, 1])
>>> ip = InsetPosition(ax, [0.5, 0.1, 0.4, 0.2])
>>> ax_ins.set_axes_locator(ip)
"""
self.parent = parent
self.lbwh = lbwh

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


@docstring.dedent_interpd
class BboxPatch(Patch):
"""
Patch showing the shape bounded by a Bbox.
@docstring.dedent_interpd
def __init__(self, bbox, **kwargs):
"""
Patch showing the shape bounded by a Bbox.

Parameters
----------
bbox : `matplotlib.transforms.Bbox`
Bbox to use for the extents of this patch.
Parameters
----------
bbox : `matplotlib.transforms.Bbox`
Bbox to use for the extents of this patch.

The kwargs are Patch properties:
%(Patch)s
"""
def __init__(self, bbox, **kwargs):
The kwargs are Patch properties:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this in a Notes section to keep numpydoc happy?

%(Patch)s
"""
if "transform" in kwargs:
raise ValueError("transform should not be set")

Expand Down Expand Up @@ -188,37 +188,7 @@ def get_path(self):
get_path.__doc__ = Patch.get_path.__doc__


@docstring.dedent_interpd
class BboxConnector(Patch):
"""
Connect two bboxes with a straight line.

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

loc1 : {1, 2, 3, 4}
Corner of *bbox1* 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

The kwargs are Patch properties for the line drawn:
%(Patch)s
"""

@staticmethod
def get_bbox_edge_pos(bbox, loc):
"""
Expand Down Expand Up @@ -305,7 +275,36 @@ def connect_bbox(bbox1, bbox2, loc1, loc2=None):

return Path(verts, codes)

@docstring.dedent_interpd
def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
"""
Connect two bboxes with a straight line.

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

loc1 : {1, 2, 3, 4}
Corner of *bbox1* 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

The kwargs are Patch properties for the line drawn:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with the Notes section here

%(Patch)s
"""
if "transform" in kwargs:
raise ValueError("transform should not be set")

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


@docstring.dedent_interpd
class BboxConnectorPatch(BboxConnector):
"""
Connect two bboxes with a quadrilateral.
@docstring.dedent_interpd
def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
"""
Connect two bboxes with a quadrilateral.

The quadrilateral is specified by two lines that start and end at corners
of the bboxes. The four sides of the quadrilateral are defined by the two
lines given, the line between the two corners specified in *bbox1* and the
line between the two corners specified in *bbox2*.
The quadrilateral is specified by two lines that start and end at corners
of the bboxes. The four sides of the quadrilateral are defined by the two
lines given, the line between the two corners specified in *bbox1* and the
line between the two corners specified in *bbox2*.

Parameters
----------
bbox1, bbox2 : `matplotlib.transforms.Bbox`
Bounding boxes to connect.
Parameters
----------
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::
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
'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::
loc1b, loc2b : {1, 2, 3, 4}
Corners of *bbox1* and *bbox2* to draw the second line.
Valid values are::

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

The kwargs are Patch properties for the line drawn:
%(Patch)s
"""
def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
The kwargs are Patch properties for the line drawn:
%(Patch)s
"""
if "transform" in kwargs:
raise ValueError("transform should not be set")
BboxConnector.__init__(self, bbox1, bbox2, loc1a, loc2a, **kwargs)
Expand Down