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

Commitdefce2e

Browse files
authored
Merge pull request#15392 from choyiny/arrow-autoscale
Autoscale for ax.arrow()
2 parentsee15e90 +f4e7d6c commitdefce2e

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

‎doc/api/next_api_changes/behaviour.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,7 @@ Shortcuts for closing all figures now also work for the classic toolbar.
129129
There is no default shortcut any more because unintentionally closing all figures by a key press
130130
might happen too easily. You can configure the shortcut yourself
131131
using:rc:`keymap.quit_all`.
132+
133+
Autoscale for arrow
134+
~~~~~~~~~~~~~~~~~~~
135+
Calling ax.arrow() will now autoscale the axes.

‎lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4959,7 +4959,8 @@ def arrow(self, x, y, dx, dy, **kwargs):
49594959
dy=self.convert_yunits(dy)
49604960

49614961
a=mpatches.FancyArrow(x,y,dx,dy,**kwargs)
4962-
self.add_artist(a)
4962+
self.add_patch(a)
4963+
self._request_autoscale_view()
49634964
returna
49644965

49654966
@docstring.copy(mquiver.QuiverKey.__init__)

‎lib/matplotlib/tests/test_axes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ def test_arrow_empty():
468468
ax.arrow(0,0,0,0,head_length=0)
469469

470470

471+
deftest_arrow_in_view():
472+
_,ax=plt.subplots()
473+
ax.arrow(1,1,1,1)
474+
assertax.get_xlim()== (0.8,2.2)
475+
assertax.get_ylim()== (0.8,2.2)
476+
477+
471478
deftest_annotate_default_arrow():
472479
# Check that we can make an annotation arrow with only default properties.
473480
fig,ax=plt.subplots()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp