Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit330f33a

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 flawsof arrow() more prominently.
1 parent3fb9c09 commit330f33a

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,9 +5432,21 @@ def on_changed(collection):
54325432
@_docstring.interpd
54335433
defarrow(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)``.
5438+
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="->"))
54385450
54395451
Parameters
54405452
----------
@@ -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)

[8]ページ先頭

©2009-2025 Movatter.jp