title: How to use an image instead of a marker in an animated graph using Matplot.lib
body: <p>I have been trying to use an image that moves in an animation instead of &quot;ro&quot; (red dots) or similar markers. <a href="https://i.stack.imgur.com/3DTWQ.png" rel="nofollow noreferrer">image_1</a>, <a href="https://i.stack.imgur.com/F8R6O.png" rel="nofollow noreferrer">image_2</a>, <a href="https://i.stack.imgur.com/l2eq9.png" rel="nofollow noreferrer">image_3</a> So far I have a graph that has a little red dot moving over the dotted line. I want an image to be the one that moves through the dotted line instead of a red dot.</p>
  <p>Here is my code:</p>
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from matplotlib.animation import FuncAnimation
  
  fig, ax = plt.subplots()
  xdata, ydata = [], []
  
  img = plt.imread(&quot;/Users/salomondabbah/Desktop/mar.jpg&quot;)
  ax.imshow(img, extent=[0, 2 * np.pi, -1, 1])
  
  xtrack = np.linspace(0, 2 * np.pi, 240)
  ytrack = np.sin(xtrack)
  ln, = plt.plot([], [], ***'ro'***, zorder=15)
  
  ax.plot(xtrack, np.sin(xtrack), 'k', linewidth=25.0, zorder=5)
  ax.plot(xtrack, ytrack, '--y',linewidth=2.0, zorder=10)
  
  def init():
      ax.set_xlim(0, 2*np.pi)
      ax.set_ylim(-1, 1)
      return ln,
  
  def update(frame):
      ln.set_data(frame, np.sin(frame))
      return ln,
  
  ani = FuncAnimation(fig, update, frames=np.linspace(0, 2*np.pi, 128),
                      init_func=init, blit=False)
  plt.show()
  </code></pre>
  <p>Thank you in advance for any solutions provided to my issue!</p>