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

Commit90794e4

Browse files
committed
autoscale arrow
1 parent74ed294 commit90794e4

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
@@ -17,3 +17,7 @@ Previously, it did not necessarily have such an attribute. A check for
1717
``hasattr(figure.canvas, "manager")`` should now be replaced by
1818
``figure.canvas.manager is not None`` (or ``getattr(figure.canvas, "manager", None) is not None``
1919
for back-compatibility).
20+
21+
Autoscale for arrow
22+
~~~~~~~~~~~~~~~~~~~
23+
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
@@ -4938,7 +4938,8 @@ def arrow(self, x, y, dx, dy, **kwargs):
49384938
dy=self.convert_yunits(dy)
49394939

49404940
a=mpatches.FancyArrow(x,y,dx,dy,**kwargs)
4941-
self.add_artist(a)
4941+
self.add_patch(a)
4942+
self._request_autoscale_view()
49424943
returna
49434944

49444945
@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
@@ -382,6 +382,13 @@ def test_arrow_empty():
382382
ax.arrow(0,0,0,0,head_length=0)
383383

384384

385+
deftest_arrow_in_view():
386+
_,ax=plt.subplots()
387+
ax.arrow(1,1,1,1)
388+
assertax.get_xlim()== (0.8,2.2)
389+
assertax.get_ylim()== (0.8,2.2)
390+
391+
385392
deftest_annotate_default_arrow():
386393
# Check that we can make an annotation arrow with only default properties.
387394
fig,ax=plt.subplots()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp