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.
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!"""importnumpyasnpimportmatplotlib.pyplotaspltimportmpl_toolkits.mplot3d.axes3dasp3importmatplotlib.animationasanimationdefGen_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)
forindexinrange(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] +stepreturnlineDatadefupdate_lines(num, dataLines, lines):
forline, datainzip(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])
returnlines# Attaching 3D axis to the figurefig=plt.figure()
ax=p3.Axes3D(fig)
# Fifty lines of random 3-D linesdata= [Gen_RandLine(100, 3) forindexinrange(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] fordatindata]
# Setting the axes propertiesax.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 objectline_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!"""importnumpyasnpimportmatplotlib.pyplotaspltimportmpl_toolkits.mplot3d.axes3dasp3importmatplotlib.animationasanimationdefGen_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)
forindexinrange(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] +stepreturnlineDatadefupdate_lines(num, dataLines, lines):
forline, datainzip(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])
returnlines# Attaching 3D axis to the figurefig=plt.figure()
ax=p3.Axes3D(fig)
# Fifty lines of random 3-D linesdata= [Gen_RandLine(100, 3) forindexinrange(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] fordatindata]
# Setting the axes propertiesax.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 objectline_ani=animation.FuncAnimation(fig, update_lines, 100, fargs=(data, lines),
interval=50, blit=True)
plt.show()
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...
Activity
san-chang commented on Feb 27, 2017
code example:
lag while drap figure window
can not rotator or scale plot using mouse:
WeatherGod commented on Feb 27, 2017
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...
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.
timhoffm commented on Oct 23, 2019
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.
anntzer commented on Mar 30, 2020
This has likely been fixed by #16070 (only in master), so closing, but feel free to request a reopen with a repro on master.