8000 DOC : add documentation to Polygon methods by tacaswell · Pull Request #3123 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

DOC : add documentation to Polygon methods #3123

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 1 commit into from
Jun 7, 2014
Merged
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
43 changes: 43 additions & 0 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,21 +858,64 @@ def __init__(self, xy, closed=True, **kwargs):
self.set_xy(xy)

def get_path(self):
"""
Get the path of the polygon

Returns
-------
path : Path
Copy link
Member

Choose a reason for hiding this comment

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

You should probably cross-ref the Path class.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is the easiest way to do that? I was hoping sphinx would auto-magically do that for this...

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be:

:class:`Path`

or whatever the resolvable name would be at that point in the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated and forced.

The :class:`~matplotlib.path.Path` object for
the polygon
"""
return self._path

def get_closed(self):
"""
Returns if the polygon is closed

Returns
-------
closed : bool
If the path is closed
"""
return self._closed

def set_closed(self, closed):
"""
Set if the polygon is closed

Parameters
----------
closed : bool
True if the polygon is closed
"""
if self._closed == bool(closed):
return
self._closed = bool(closed)
self.set_xy(self.get_xy())

def get_xy(self):
"""
Get the vertices of the path

Returns
-------
vertices : numpy array
The coordinates of the vertices as a Nx2
ndarray.
"""
return self._path.vertices

def set_xy(self, xy):
"""
Set the vertices of the polygon

Parameters
----------
xy : numpy array or iterable of pairs
The coordinates of the vertices as a Nx2
ndarray or iterable of pairs.
"""
xy = np.asarray(xy)
if self._closed:
if len(xy) and (xy[0] != xy[-1]).any():
Expand Down
0