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

Make set_x/ymargin() update axes limits, just like margins().#16340

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
efiring merged 1 commit intomatplotlib:masterfromanntzer:set_xmargin-autoscale
May 18, 2020
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
8 changes: 4 additions & 4 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2294,6 +2294,7 @@ def set_xmargin(self, m):
if m <= -0.5:
raise ValueError("margin must be greater than -0.5")
self._xmargin = m
self._request_autoscale_view(scalex=True, scaley=False)
self.stale = True

def set_ymargin(self, m):
Expand All@@ -2316,6 +2317,7 @@ def set_ymargin(self, m):
if m <= -0.5:
raise ValueError("margin must be greater than -0.5")
self._ymargin = m
self._request_autoscale_view(scalex=False, scaley=True)
self.stale = True

def margins(self, *margins, x=None, y=None, tight=True):
Expand DownExpand Up@@ -2386,15 +2388,13 @@ def margins(self, *margins, x=None, y=None, tight=True):
cbook._warn_external(f'ignoring tight={tight!r} in get mode')
return self._xmargin, self._ymargin

if tight is not None:
self._tight = tight
if x is not None:
self.set_xmargin(x)
if y is not None:
self.set_ymargin(y)

self._request_autoscale_view(
tight=tight, scalex=(x is not None), scaley=(y is not None)
)

def set_rasterization_zorder(self, z):
"""
Parameters
Expand Down
8 changes: 8 additions & 0 deletionslib/matplotlib/tests/test_axes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4582,6 +4582,14 @@ def test_margins():
ymax + (ymax - ymin) * 0.5)


def test_set_margin_updates_limits():
mpl.style.use("default")
fig, ax = plt.subplots()
ax.plot([1, 2], [1, 2])
ax.set(xscale="log", xmargin=0)
assert ax.get_xlim() == (1, 2)


def test_length_one_hist():
fig, ax = plt.subplots()
ax.hist(1)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp