Skip to content

[Doc]: Axes limits not updated in animate decay #24296

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
story645 opened this issue Oct 28, 2022 · 3 comments · Fixed by #24310
Closed

[Doc]: Axes limits not updated in animate decay #24296

story645 opened this issue Oct 28, 2022 · 3 comments · Fixed by #24310
Milestone

Comments

@story645
Copy link
Member

story645 commented Oct 28, 2022

Documentation Link

https://matplotlib.org/devdocs/gallery/animation/animate_decay.html#sphx-glr-gallery-animation-animate-decay-py

Problem

Animate decay claims it shows how to changing axes limits during an animation in the run method

def run(data):
    # update the data
    t, y = data
    xdata.append(t)
    ydata.append(y)
    xmin, xmax = ax.get_xlim()

    if t >= xmax:
        ax.set_xlim(xmin, 2*xmax)
        ax.figure.canvas.draw()
    line.set_data(xdata, ydata)

but the limits aren't actually changing:

91679bc3-c559-48dd-8c6e-9f7e9a8157bd.mp4

Suggested improvement

Either option is fine with me:

  • fix code so xlims dynamically updated
  • remove lim updating code and statement saying this example shows how to update limits
@QuLogic
Copy link
Member

QuLogic commented Oct 29, 2022

The example works, but that's the default xlim, and it is not running long enough in the docs to show the change. I'm not sure where the cutoff is, as the code itself runs infinitely.

story645 added a commit to story645/matplotlib that referenced this issue Oct 30, 2022
@story645 story645 linked a pull request Oct 30, 2022 that will close this issue
@story645
Copy link
Member Author

story645 commented Oct 30, 2022

Sphinx gallery is using the default animation save
https://github.com/sphinx-gallery/sphinx-gallery/blob/e2ecb35d9049d0df0a1db4f6d15be817745cd565/sphinx_gallery/scrapers.py#L232

And a really rough experiment indicates that the default save is 100 frames which was apparently deprecated in 2.2, but isn't in the release notes 😕

_api.warn_deprecated(
"2.2", message="FuncAnimation.save has truncated "
"your animation to 100 frames. In the future, no "
"such truncation will occur; please pass "
"'save_count' accordingly.")

@oscargus
Copy link
Member

Slightly related to #24131 (which removes the automatic truncation).

@QuLogic QuLogic added this to the v3.6.2 milestone Nov 1, 2022
melissawm pushed a commit to melissawm/matplotlib that referenced this issue Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants