FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Unable to disable autoscaling in pyplot.plot · Issue #17955 · matplotlib/matplotlib · GitHub

Repository navigation

Unable to disable autoscaling in pyplot.plot #17955

Open

Description

Bug report

Bug summary

Arguments to disable autoscaling are not working, so despite e.g. scalex=False the horizontal axis is re-scaled.

Code for reproduction

import matplotlib.pyplot as plt

plt.plot([0, 2], [0, 2], '-')
plt.plot([0, 10], [1, 1], '-', scalex=False)

Actual outcome

Output in-line in jupyter notebook:

Expected outcome

Expected autoscaling only for the first call, so the xscale is just a bit padded from [0, 2]. This works as expected in matplotlib==3.1.3:

Matplotlib version

  • Operating system: Ubuntu 18.04.3
  • Matplotlib version: 3.3.0
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6.8
  • Jupyter version (if applicable): 1.0.0
  • Other libraries: N/A

Tools installed with pip

Activity

  1. QuLogic commented on Jul 18, 2020

    Member

    This comes from 160de56, or #13593. This may be an expected change; see the API note from that PR.

    cc @anntzer

  2. neilpeterman commented on Jul 18, 2020

    Author

    Thanks for the clarification @QuLogic -- so the way to achieve the previous behavior would be to do something like this:

    plt.plot([0, 2], [0, 2], '-')
    plt.gcf().canvas.draw()
    plt.plot([0, 10], [1, 1], '-', scalex=False)

    The concept of delaying autoscaling makes sense to me, although in the example above the meaning of scalex=False is not so intuitive to me -- I would think anything with scalex=False should be excluded from the autoscaling process in one way or another. Does that sound like a reasonable expectation?

    I'm not sure -- it could be that I'm just accustomed to the previous behavior.

  3. anntzer commented on Jul 18, 2020

    Contributor

    I guess what you really want is more along the lines of #15595?
    In the meantime we could trigger an autoscale when scalex/scaley goes from True to False, i.e. in _request_autoscale_view, something like if self._stale_viewlim_x and not scalex or self._stale_viewlim_y and not scaley: self._unstale_viewlim()? (untested, but hopefully you get the idea...)

  4. neilpeterman commented on Jul 21, 2020

    Author

    It seems like the fixes you bring up would address the issue in a reasonable way, triggering autoscaling when needed.

  5. igurin-invn commented on May 29, 2023

    Contributor

    Just a little poke: this bug is still open. Whether or not it results from an intentional change in #13593, it's not reflected in the documentation.

    scalex, scaleybool, default: True
    These parameters determine if the view limits are adapted to the data limits. The values are passed on to autoscale_view.

  6. anntzer commented on Jun 3, 2023

    Contributor

    Good point. I think scalex/scaley should be deprecated in favor of #15595 once something like that gets in, but in the meantime the following seems to work OKish, going back to the old semantics:

    diff --git i/lib/matplotlib/axes/_axes.py w/lib/matplotlib/axes/_axes.py
    index 5369eadbde..2b08537ef1 100644
    --- i/lib/matplotlib/axes/_axes.py
    +++ w/lib/matplotlib/axes/_axes.py
    @@ -1719,6 +1719,8 @@ class Axes(_AxesBase):
             additionally use any  `matplotlib.colors` spec, e.g. full names
             (``'green'``) or hex strings (``'#008000'``).
             """
    +        if not scalex or not scaley:
    +            self._unstale_viewLim()
             kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
             lines = [*self._get_lines(*args, data=data, **kwargs)]
             for line in lines:

    (note that using scalex/scaley=False then implies some runtime cost, as explained in 160de56)

  7. igurin-invn commented on Jun 4, 2023

    Contributor

    Is there a better workaround than this?

    _xlim = ax.get_xlim()
    ax.plot(x_big, y)
    ax.set_xlim(_xlim)
  8. github-actions commented on Aug 3, 2026

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL