Skip to content

Arrow patch docstring clean #8770

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
Jul 28, 2017
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
16 changes: 8 additions & 8 deletions examples/shapes_and_collections/artist_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def label(xy, text):
label(grid[4], "Ellipse")

# add an arrow
arrow = mpatches.Arrow(grid[5, 0] - 0.05, grid[5, 1] - 0.05, 0.1, 0.1, width=0.1)
arrow = mpatches.Arrow(grid[5, 0] - 0.05, grid[5, 1] - 0.05, 0.1, 0.1,
width=0.1)
patches.append(arrow)
label(grid[5], "Arrow")

Expand All @@ -67,14 +68,13 @@ def label(xy, text):
path_data = [
(Path.MOVETO, [0.018, -0.11]),
(Path.CURVE4, [-0.031, -0.051]),
(Path.CURVE4, [-0.115, 0.073]),
(Path.CURVE4, [-0.03 , 0.073]),
(Path.LINETO, [-0.011, 0.039]),
(Path.CURVE4, [0.043, 0.121]),
(Path.CURVE4, [-0.115, 0.073]),
(Path.CURVE4, [-0.03, 0.073]),
(Path.LINETO, [-0.011, 0.039]),
(Path.CURVE4, [0.043, 0.121]),
(Path.CURVE4, [0.075, -0.005]),
(Path.CURVE4, [0.035, -0.027]),
(Path.CLOSEPOLY, [0.018, -0.11])
]
(Path.CLOSEPOLY, [0.018, -0.11])]
codes, verts = zip(*path_data)
path = mpath.Path(verts + grid[6], codes)
patch = mpatches.PathPatch(path)
Expand All @@ -99,8 +99,8 @@ def label(xy, text):
ax.add_collection(collection)
ax.add_line(line)

plt.subplots_adjust(left=0, right=1, bottom=0, top=1)
plt.axis('equal')
plt.axis('off')
plt.tight_layout()

plt.show()
41 changes: 31 additions & 10 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,21 +1131,42 @@ class Arrow(Patch):
def __str__(self):
return "Arrow()"

_path = Path([
[0.0, 0.1], [0.0, -0.1],
[0.8, -0.1], [0.8, -0.3],
[1.0, 0.0], [0.8, 0.3],
[0.8, 0.1], [0.0, 0.1]],
closed=True)
_path = Path([[0.0, 0.1], [0.0, -0.1],
[0.8, -0.1], [0.8, -0.3],
[1.0, 0.0], [0.8, 0.3],
[0.8, 0.1], [0.0, 0.1]],
closed=True)

@docstring.dedent_interpd
def __init__(self, x, y, dx, dy, width=1.0, **kwargs):
"""
Draws an arrow, starting at (*x*, *y*), direction and length
given by (*dx*, *dy*) the width of the arrow is scaled by *width*.
Draws an arrow from (*x*, *y*) to (*x* + *dx*, *y* + *dy*).
Copy link
Contributor

Choose a reason for hiding this comment

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

would do use double backquotes around each parenthesis instead.

The width of the arrow is scaled by *width*.

Valid kwargs are:
%(Patch)s
Parameters
----------
x : scalar
x coordinate of the arrow tail
y : scalar
y coordinate of the arrow tail
dx : scalar
Arrow length in the x direction
dy : scalar
Arrow length in the y direction
width : scalar, optional (default: 1)
Scale factor for the width of the arrow. With a default value of
1, the tail width is 0.2 and head width is 0.6.
**kwargs :
Keyword arguments control the :class:`~matplotlib.patches.Patch`
properties:

%(Patch)s

See Also
--------
:class:`FancyArrow` :
Patch that allows independent control of the head and tail
properties
"""
Patch.__init__(self, **kwargs)
L = np.hypot(dx, dy)
Expand Down