8000 Don't try to autoscale if no data present to autoscale to by dstansby · Pull Request #12284 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Don't try to autoscale if no data present to autoscale to #12284

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/next_api_changes/2018-09-25-DS-autoscale.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Autoscaling when no data present
--------------------------------

`.Axes.autoscale_view` now does not attempt to autoscale an axis if there is no
data with finite coordinates present to use to determine the autoscaling.
8 changes: 6 additions & 2 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2372,8 +2372,9 @@ def autoscale_view(self, tight=None, scalex=True, scaley=True):
"""
Autoscale the view limits using the data limits.

You can selectively autoscale only a single axis, e.g., the xaxis by
setting *scaley* to *False*. The autoscaling preserves any
If no data with finite coordinates is present, limits are left
unchanged. You can selectively autoscale only a single axis, e.g.,
the xaxis by setting *scaley* to *False*. The autoscaling preserves any
axis direction reversal that has already been done.

If *tight* is *False*, the axis major locator will be used
Expand Down Expand Up @@ -2426,6 +2427,9 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
dl = finite_dl
dl.extend(x_finite)
dl.extend(y_finite)
else:
# If no finite data to autoscale using, don't do anything
return

bb = mtransforms.BboxBase.union(dl)
x0, x1 = getattr(bb, interval)
Expand Down
0