title: How to live update Matplotlib plot on top of a background image?
body: <p>I'm trying to have my matplotlib plot update in real-time as data is added to a CSV file. The plot is of a small geographic location, axes given by longitude and latitude. This is what I have so far:</p>
  <pre><code>import numpy as np
  import pandas as pd
  import matplotlib
  import matplotlib.pyplot as plt
  
  df = pd.read_csv(&quot;cayugacoords.txt&quot;)
  BoundaryBox = [-76.5119, -76.5013, 42.4596, 42.4642]
  ruh_m = plt.imread('map.png')
  fig, ax = plt.subplots(figsize=(8, 7))
  
  ax.scatter(df.longitude, df.latitude, zorder=1, alpha=1, c='r', s=10)
  ax.set_title('Cayuga Lake Shore')
  ax.set_xlim(BoundaryBox[0], BoundaryBox[1])
  ax.set_ylim(BoundaryBox[2], BoundaryBox[3])
  ax.imshow(ruh_m, zorder=0, extent=BoundaryBox, aspect='equal')
  plt.show()
  </code></pre>
  <p>And this is what shows when I run the code (the three points on the bottom left are already in the CSV file):
  <a href="https://i.stack.imgur.com/aDUiP.png" rel="nofollow noreferrer">Current plot</a></p>
  <p>And here's the background image on its own: <a href="https://i.stack.imgur.com/kvqJC.png" rel="nofollow noreferrer">Cayuga Lake</a></p>
  <p>I want the map to be regularly updated as new coordinates are added to the CSV file. How can this be done? I've looked into animation tools but I'm having trouble retaining the background image of the map while updating the plot. For reference, the CSV file &quot;cayugacoords.txt&quot; looks like this:</p>
  <pre><code>longitude,latitude
  -76.51,42.46
  -76.511,42.46
  -76.5105,42.46
  </code></pre>
  <p>Thank you!</p>