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: have apply_aspect keep track of user-set limits#30265

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

Open
rcomer wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromrcomer:aspect-fixed-lims
Open
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
20 changes: 16 additions & 4 deletionslib/matplotlib/axes/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -687,6 +687,8 @@
self._forward_navigation_events = forward_navigation_events
self._sharex = sharex
self._sharey = sharey
self._orig_xbound = None
self._orig_ybound = None
self.set_label(label)
self.set_figure(fig)
# The subplotspec needs to be set after the figure (so that
Expand DownExpand Up@@ -2019,8 +2021,8 @@

x_trf = self.xaxis.get_transform()
y_trf = self.yaxis.get_transform()
xmin, xmax = x_trf.transform(self.get_xbound())
ymin, ymax = y_trf.transform(self.get_ybound())
xmin, xmax =self._orig_xbound orx_trf.transform(self.get_xbound())
ymin, ymax =self._orig_ybound ory_trf.transform(self.get_ybound())
xsize = max(abs(xmax - xmin), 1e-30)
ysize = max(abs(ymax - ymin), 1e-30)

Expand DownExpand Up@@ -2072,18 +2074,26 @@
yc = 0.5 * (ymin + ymax)
y0 = yc - Ysize / 2.0
y1 = yc + Ysize / 2.0
self.set_ybound(y_trf.inverted().transform([y0, y1]))
if not self.get_autoscaley_on():
_log.warning("Ignoring fixed y limits to fulfill fixed data aspect "
"with adjustable data limits.")
self.set_ybound(y_trf.inverted().transform([y0, y1]))
self._orig_ybound = (ymin, ymax)
if self._orig_xbound is not None:
# We previously expanded x, so revert that
self.set_xbound(x_trf.inverted().transform([xmin, xmax]))

Check warning on line 2084 in lib/matplotlib/axes/_base.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/axes/_base.py#L2084

Added line #L2084 was not covered by tests
else:
xc = 0.5 * (xmin + xmax)
x0 = xc - Xsize / 2.0
x1 = xc + Xsize / 2.0
self.set_xbound(x_trf.inverted().transform([x0, x1]))
if not self.get_autoscalex_on():
_log.warning("Ignoring fixed x limits to fulfill fixed data aspect "
"with adjustable data limits.")
self.set_xbound(x_trf.inverted().transform([x0, x1]))
self._orig_xbound = (xmin, xmax)
if self._orig_ybound is not None:
# We previously expanded y, so revert that
self.set_ybound(y_trf.inverted().transform([ymin, ymax]))

Check warning on line 2096 in lib/matplotlib/axes/_base.py

View check run for this annotation

Codecov/ codecov/patch

lib/matplotlib/axes/_base.py#L2096

Added line #L2096 was not covered by tests

def axis(self, arg=None, /, *, emit=True, **kwargs):
"""
Expand DownExpand Up@@ -3810,6 +3820,7 @@

>>> set_xlim(5000, 0)
"""
self._orig_xbound = None
if right is None and np.iterable(left):
left, right = left
if xmin is not None:
Expand DownExpand Up@@ -4059,6 +4070,7 @@

>>> set_ylim(5000, 0)
"""
self._orig_ybound = None
if top is None and np.iterable(bottom):
bottom, top = bottom
if ymin is not None:
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp