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

can not scale and rotate the plot where set "blit=True" in 3D animation figures using funcAnimation · Issue #8162 · matplotlib/matplotlib · GitHub

Repository navigation

can not scale and rotate the plot where set "blit=True" in 3D animation figures using funcAnimation #8162

Closed

Description

Bug report

Bug summary
can not scale and rotate the plot where set "blit=True" in 3D animation figures using funcAnimation
when I set "blit" to False, I can control the plot with mouse, but it's become very lagging when I drag or scale the figure window.

It's seems work well with 2D animation plot.

Code for reproduction

anim = FuncAnimation(fig, animate, init_func=init, frames=500, interval=5, blit=True)

Matplotlib version

  • I'm using Python2.7 in Windows 10 with Matplotlib 2.0.0 installed

Activity

  1. san-chang commented on Feb 27, 2017

    Author

    code example:

    I'd like to know if all user have the same problem or just me

    lag while drap figure window

    """
    ============
    3D animation
    ============
    
    A simple example of an animated plot... In 3D!
    """
    import numpy as np
    import matplotlib.pyplot as plt
    import mpl_toolkits.mplot3d.axes3d as p3
    import matplotlib.animation as animation
    
    
    def Gen_RandLine(length, dims=2):
        """
        Create a line using a random walk algorithm
    
        length is the number of points for the line.
        dims is the number of dimensions the line has.
        """
        lineData = np.empty((dims, length))
        lineData[:, 0] = np.random.rand(dims)
        for index in range(1, length):
            # scaling the random numbers by 0.1 so
            # movement is small compared to position.
            # subtraction by 0.5 is to change the range to [-0.5, 0.5]
            # to allow a line to move backwards.
            step = ((np.random.rand(dims) - 0.5) * 0.1)
            lineData[:, index] = lineData[:, index - 1] + step
    
        return lineData
    
    
    def update_lines(num, dataLines, lines):
        for line, data in zip(lines, dataLines):
            # NOTE: there is no .set_data() for 3 dim data...
            line.set_data(data[0:2, :num])
            line.set_3d_properties(data[2, :num])
        return lines
    
    # Attaching 3D axis to the figure
    fig = plt.figure()
    ax = p3.Axes3D(fig)
    
    # Fifty lines of random 3-D lines
    data = [Gen_RandLine(100, 3) for index in range(50)]
    
    # Creating fifty line objects.
    # NOTE: Can't pass empty arrays into 3d version of plot()
    lines = [ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1])[0] for dat in data]
    
    # Setting the axes properties
    ax.set_xlim3d([0.0, 1.0])
    ax.set_xlabel('X')
    
    ax.set_ylim3d([0.0, 1.0])
    ax.set_ylabel('Y')
    
    ax.set_zlim3d([0.0, 1.0])
    ax.set_zlabel('Z')
    
    ax.set_title('3D Test')
    
    # Creating the Animation object
    line_ani = animation.FuncAnimation(fig, update_lines, 100, fargs=(data, lines),
                                       interval=50, blit=False)
    
    plt.show()

    can not rotator or scale plot using mouse:

    """
    ============
    3D animation
    ============
    
    A simple example of an animated plot... In 3D!
    """
    import numpy as np
    import matplotlib.pyplot as plt
    import mpl_toolkits.mplot3d.axes3d as p3
    import matplotlib.animation as animation
    
    
    def Gen_RandLine(length, dims=2):
        """
        Create a line using a random walk algorithm
    
        length is the number of points for the line.
        dims is the number of dimensions the line has.
        """
        lineData = np.empty((dims, length))
        lineData[:, 0] = np.random.rand(dims)
        for index in range(1, length):
            # scaling the random numbers by 0.1 so
            # movement is small compared to position.
            # subtraction by 0.5 is to change the range to [-0.5, 0.5]
            # to allow a line to move backwards.
            step = ((np.random.rand(dims) - 0.5) * 0.1)
            lineData[:, index] = lineData[:, index - 1] + step
    
        return lineData
    
    
    def update_lines(num, dataLines, lines):
        for line, data in zip(lines, dataLines):
            # NOTE: there is no .set_data() for 3 dim data...
            line.set_data(data[0:2, :num])
            line.set_3d_properties(data[2, :num])
        return lines
    
    # Attaching 3D axis to the figure
    fig = plt.figure()
    ax = p3.Axes3D(fig)
    
    # Fifty lines of random 3-D lines
    data = [Gen_RandLine(100, 3) for index in range(50)]
    
    # Creating fifty line objects.
    # NOTE: Can't pass empty arrays into 3d version of plot()
    lines = [ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1])[0] for dat in data]
    
    # Setting the axes properties
    ax.set_xlim3d([0.0, 1.0])
    ax.set_xlabel('X')
    
    ax.set_ylim3d([0.0, 1.0])
    ax.set_ylabel('Y')
    
    ax.set_zlim3d([0.0, 1.0])
    ax.set_zlabel('Z')
    
    ax.set_title('3D Test')
    
    # Creating the Animation object
    line_ani = animation.FuncAnimation(fig, update_lines, 100, fargs=(data, lines),
                                       interval=50, blit=True)
    
    plt.show()
  2. WeatherGod commented on Feb 27, 2017

    Member

    Yes, this is a known issue that hasn't been fully fixed in mplot3d. It works in 2d because the blitting code has taken into account most of the interactivity events that matplotlib comes with normally. So, the blitting code knows to re-capture the background image after a pan/zoom. However, the mplot3d code adds new events for its interactivity, and as such, the blitting code does not know to re-capture the background image.

    Might be a fun little task for an adventurous soul...

  3. added this to the milestone on Feb 27, 2017
  4. wlxing1901 commented on Oct 23, 2019

    I met the same issue, is the bug fixed in version 2.2? I use matplotlib 3.1.0 and still find the issue.

  5. timhoffm commented on Oct 23, 2019

    Member

    Since this is still open and no PR references this and you're still finding the issue in 3.1, I have no indication that it could be fixed.

  6. anntzer commented on Mar 30, 2020

    Contributor

    This has likely been fixed by #16070 (only in master), so closing, but feel free to request a reopen with a repro on master.

  7. removed this from the future releases milestone on Oct 6, 2022
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