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

FIX: re-instate ability to have position in axes#21443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:mainfromjklymak:fix-position-axes
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletionlib/matplotlib/pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1059,8 +1059,12 @@ def axes(arg=None, **kwargs):
plt.axes((left, bottom, width, height), facecolor='w')
"""
fig = gcf()
pos = kwargs.pop('position', None)
if arg is None:
return fig.add_subplot(**kwargs)
if pos is None:
return fig.add_subplot(**kwargs)
else:
return fig.add_axes(pos, **kwargs)
else:
return fig.add_axes(arg, **kwargs)

Expand Down
15 changes: 15 additions & 0 deletionslib/matplotlib/tests/test_pyplot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
import difflib
import numpy as np
import subprocess
import sys
from pathlib import Path
Expand DownExpand Up@@ -320,3 +321,17 @@ def test_polar_second_call():
ln2, = plt.polar(1.57, .5, 'bo')
assert isinstance(ln2, mpl.lines.Line2D)
assert ln1.axes is ln2.axes


def test_fallback_position():
# check that position kwarg works if rect not supplied
axref = plt.axes([0.2, 0.2, 0.5, 0.5])
axtest = plt.axes(position=[0.2, 0.2, 0.5, 0.5])
np.testing.assert_allclose(axtest.bbox.get_points(),
axref.bbox.get_points())

# check that position kwarg ignored if rect is supplied
axref = plt.axes([0.2, 0.2, 0.5, 0.5])
axtest = plt.axes([0.2, 0.2, 0.5, 0.5], position=[0.1, 0.1, 0.8, 0.8])
np.testing.assert_allclose(axtest.bbox.get_points(),
axref.bbox.get_points())

[8]ページ先頭

©2009-2025 Movatter.jp