Bug report
Bug summary
When using blitting in an animation the figure window can be resized and the plot can be zoomed without problem while the animation is running.
However after the animation finishes (repeat=False), the content is not redrawn to the canvas and the axes become empty on zooming/panning/resizing.
This issue was raised on Stackoverflow: https://stackoverflow.com/questions/52806527/how-can-i-keep-the-last-frame-when-i-use-matplotlib-animation-function-with-blit
Code for reproduction
Code taken from the simple animation example and adapted to use repeat=False and equipped with a callback to print the line visibility.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
x = np.arange(0, 2*np.pi, 0.01)
line, = ax.plot(x, np.sin(x))
def init(): # only required for blitting to give a clean slate.
line.set_ydata([np.nan] * len(x))
return line,
def animate(i):
line.set_ydata(np.sin(x + i / 100.)) # update the data.
return line,
ani = animation.FuncAnimation(
fig, animate, init_func=init, frames=100, interval=20, blit=True, repeat=False)
def ondraw(evt):
print(line.get_visible())
fig.canvas.mpl_connect("draw_event", ondraw)
plt.show()
To reproduce, wait till the animation finishes, then resize the window or zoom or pan in the axes.
Actual outcome
An empty axes after zooming, panning, resizing.
Even though the connected ondraw callback prints True for the visibility of the line througout.
Expected outcome
The line should be visible.
Matplotlib version
- Operating system: Win8
- Matplotlib version: 2.0.2, 3.0.0
- Matplotlib backend (
print(matplotlib.get_backend())): Qt5Agg
- Python version: 3.6
Bug report
Bug summary
When using blitting in an animation the figure window can be resized and the plot can be zoomed without problem while the animation is running.
However after the animation finishes (
repeat=False), the content is not redrawn to the canvas and the axes become empty on zooming/panning/resizing.This issue was raised on Stackoverflow: https://stackoverflow.com/questions/52806527/how-can-i-keep-the-last-frame-when-i-use-matplotlib-animation-function-with-blit
Code for reproduction
Code taken from the simple animation example and adapted to use
repeat=Falseand equipped with a callback to print the line visibility.To reproduce, wait till the animation finishes, then resize the window or zoom or pan in the axes.
Actual outcome
An empty axes after zooming, panning, resizing.
Even though the connected
ondrawcallback printsTruefor the visibility of the line througout.Expected outcome
The line should be visible.
Matplotlib version
print(matplotlib.get_backend())): Qt5Agg