Skip to content

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

Closed

Description

@story645

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

Activity

  1. QuLogic commented on Oct 29, 2022

    @QuLogic
    Member

    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.

  2. added a commit that references this issue on Oct 30, 2022
    001ece8
  3. story645 commented on Oct 30, 2022

    @story645
    MemberAuthor

    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.")

  4. oscargus commented on Oct 30, 2022

    @oscargus
    Member

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

  5. added this to the v3.6.2 milestone on Nov 1, 2022
  6. added a commit that references this issue on Dec 19, 2022
    b5af605
  7. added 3 commits that reference this issue on Apr 19, 2026
    3246e18
    0ed9320
    a883a40
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions