Question
Making an image move in matplotlib
I'm trying to have an image rotate and translate in matplotlib according to a predefined pattern.
I'm trying to use FuncAnimation
and Affine2D
to achieve this. My code looks something like this :
from matplotlib.animation import FumcAnimation
from matplotlib.transforms import Affine2D
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
img = ax.imgshow(plt.imread("demo.png"),aspect="equal")
def update(i):
if i>0: img.set_transform(Affine2D().translate(1,0))
return img
anim=FuncAnimation(fig,update,frames=(0,1))
plt.show()
Instead of the image moving right, it disappears.
3 41
3