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

Appearance settings

Commit defce2e

Browse filesBrowse files
authored
Merge pull request #15392 from choyiny/arrow-autoscale
Autoscale for ax.arrow()
2 parents ee15e90 + f4e7d6c commit defce2e
Copy full SHA for defce2e

File tree

Expand file treeCollapse file tree

3 files changed

+13
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+13
-1
lines changed

‎doc/api/next_api_changes/behaviour.rst

Copy file name to clipboardExpand all lines: doc/api/next_api_changes/behaviour.rst
+4Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+2-1Lines 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
return a
49644965

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

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+7Lines 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+
def test_arrow_in_view():
472+
_, ax = plt.subplots()
473+
ax.arrow(1, 1, 1, 1)
474+
assert ax.get_xlim() == (0.8, 2.2)
475+
assert ax.get_ylim() == (0.8, 2.2)
476+
477+
471478
def test_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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.