8000 MNT: Discourage arrow() · matplotlib/matplotlib@a74bf6d · GitHub
[go: up one dir, main page]

Skip to content

Commit a74bf6d

Browse files
committed
MNT: Discourage arrow()
The arrow() design is broken beyond repair. Even though we currently only have to offer `annotate` as a workaround, we should make the limitations more prominent then just a note and we should steer users away. This is a a step towards deprecation (#20387). Unfortunately the discussion of a replacement has stalled (#22435) and we have to revive it later. But that shound not hold us from pointing out the flaws of arrow() more prominently.
1 parent 3fb9c09 commit a74bf6d

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5432,10 +5432,22 @@ def on_changed(collection):
54325432
@_docstring.interpd
54335433
def arrow(self, x, y, dx, dy, **kwargs):
54345434
"""
5435-
Add an arrow to the Axes.
5435+
[*Discouraged*] Add an arrow to the Axes.
54365436
54375437
This draws an arrow from ``(x, y)`` to ``(x+dx, y+dy)``.
54385438
5439+
.. admonition:: Discouraged
5440+
5441+
The use of this method is discouraged because it is not guaranteed
5442+
that the arrow renders reasonably. For example, the resulting arrow
5443+
is affected by the Axes aspect ratio and limits, which may distort
5444+
the arrow.
5445+
5446+
Consider using `~.Axes.annotate` without a text instead, e.g. ::
5447+
5448+
ax.annotate("", xytext=(0, 0), xy=(0.5, 0.5),
5449+
arrowprops=dict(arrowstyle="->"))
5450+
54395451
Parameters
54405452
----------
54415453
%(FancyArrow)s
@@ -5444,17 +5456,6 @@ def arrow(self, x, y, dx, dy, **kwargs):
54445456
-------
54455457
`.FancyArrow`
54465458
The created `.FancyArrow` object.
5447-
5448-
Notes
5449-
-----
5450-
The resulting arrow is affected by the Axes aspect ratio and limits.
5451-
This may produce an arrow whose head is not square with its stem. To
5452-
create an arrow whose head is square with its stem,
5453-
use :meth:`annotate` for example:
5454-
5455-
>>> ax.annotate("", xy=(0.5, 0.5), xytext=(0, 0),
5456-
... arrowprops=dict(arrowstyle="->"))
5457-
54585459
"""
54595460
# Strip away units for the underlying patch since units
54605461
# do not make sense to most patch-like code

0 commit comments

Comments
 (0)
0