Skip to content

Commit 1a835d9

Browse files
authored
Merge pull request #8770 from dstansby/arrowpatch-docstring
Arrow patch docstring clean
2 parents 0d1d968 + 3af7102 commit 1a835d9

File tree

2 files changed

+39
-18
lines changed

2 files changed

+39
-18
lines changed

examples/shapes_and_collections/artist_reference.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def label(xy, text):
5858
label(grid[4], "Ellipse")
5959

6060
# add an arrow
61-
arrow = mpatches.Arrow(grid[5, 0] - 0.05, grid[5, 1] - 0.05, 0.1, 0.1, width=0.1)
61+
arrow = mpatches.Arrow(grid[5, 0] - 0.05, grid[5, 1] - 0.05, 0.1, 0.1,
62+
width=0.1)
6263
patches.append(arrow)
6364
label(grid[5], "Arrow")
6465

@@ -67,14 +68,13 @@ def label(xy, text):
6768
path_data = [
6869
(Path.MOVETO, [0.018, -0.11]),
6970
(Path.CURVE4, [-0.031, -0.051]),
70-
(Path.CURVE4, [-0.115, 0.073]),
71-
(Path.CURVE4, [-0.03 , 0.073]),
72-
(Path.LINETO, [-0.011, 0.039]),
73-
(Path.CURVE4, [0.043, 0.121]),
71+
(Path.CURVE4, [-0.115, 0.073]),
72+
(Path.CURVE4, [-0.03, 0.073]),
73+
(Path.LINETO, [-0.011, 0.039]),
74+
(Path.CURVE4, [0.043, 0.121]),
7475
(Path.CURVE4, [0.075, -0.005]),
7576
(Path.CURVE4, [0.035, -0.027]),
76-
(Path.CLOSEPOLY, [0.018, -0.11])
77-
]
77+
(Path.CLOSEPOLY, [0.018, -0.11])]
7878
codes, verts = zip(*path_data)
7979
path = mpath.Path(verts + grid[6], codes)
8080
patch = mpatches.PathPatch(path)
@@ -99,8 +99,8 @@ def label(xy, text):
9999
ax.add_collection(collection)
100100
ax.add_line(line)
101101

102-
plt.subplots_adjust(left=0, right=1, bottom=0, top=1)
103102
plt.axis('equal')
104103
plt.axis('off')
104+
plt.tight_layout()
105105

106106
plt.show()

lib/matplotlib/patches.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,21 +1131,42 @@ class Arrow(Patch):
11311131
def __str__(self):
11321132
return "Arrow()"
11331133

1134-
_path = Path([
1135-
[0.0, 0.1], [0.0, -0.1],
1136-
[0.8, -0.1], [0.8, -0.3],
1137-
[1.0, 0.0], [0.8, 0.3],
1138-
[0.8, 0.1], [0.0, 0.1]],
1139-
closed=True)
1134+
_path = Path([[0.0, 0.1], [0.0, -0.1],
1135+
[0.8, -0.1], [0.8, -0.3],
1136+
[1.0, 0.0], [0.8, 0.3],
1137+
[0.8, 0.1], [0.0, 0.1]],
1138+
closed=True)
11401139

11411140
@docstring.dedent_interpd
11421141
def __init__(self, x, y, dx, dy, width=1.0, **kwargs):
11431142
"""
1144-
Draws an arrow, starting at (*x*, *y*), direction and length
1145-
given by (*dx*, *dy*) the width of the arrow is scaled by *width*.
1143+
Draws an arrow from (*x*, *y*) to (*x* + *dx*, *y* + *dy*).
1144+
The width of the arrow is scaled by *width*.
11461145
1147-
Valid kwargs are:
1148-
%(Patch)s
1146+
Parameters
1147+
----------
1148+
x : scalar
1149+
x coordinate of the arrow tail
1150+
y : scalar
1151+
y coordinate of the arrow tail
1152+
dx : scalar
1153+
Arrow length in the x direction
1154+
dy : scalar
1155+
Arrow length in the y direction
1156+
width : scalar, optional (default: 1)
1157+
Scale factor for the width of the arrow. With a default value of
1158+
1, the tail width is 0.2 and head width is 0.6.
1159+
**kwargs :
1160+
Keyword arguments control the :class:`~matplotlib.patches.Patch`
1161+
properties:
1162+
1163+
%(Patch)s
1164+
1165+
See Also
1166+
--------
1167+
:class:`FancyArrow` :
1168+
Patch that allows independent control of the head and tail
1169+
properties
11491170
"""
11501171
Patch.__init__(self, **kwargs)
11511172
L = np.hypot(dx, dy)

0 commit comments

Comments
 (0)