title: update matplotlib plot
body: <p>I'm trying to update a matplotlib plot as follows:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import matplotlib.dates as mdate
  import numpy as np
  
  plt.ion()
  
  fig = plt.figure()
  ax = fig.add_subplot(111)
  
  for i,(_,_,idx) in enumerate(local_minima):
      dat = dst_data[idx-24:idx+25]
      dates,values = zip(*dat)
      if i == 0:
          assert(len(dates) == len(values))
          lines2d, = ax.plot_date(mdate.date2num(dates), np.array(values), linestyle='-')
      else:
          assert(len(dates) == len(values))
          lines2d.set_ydata(np.array(values))
          lines2d.set_xdata(mdate.date2num(dates))  #This line causes problems.
  
          fig.canvas.draw()
      raw_input()
  </code></pre>
  
  <p>The first time through the loop, the plot displays just fine.  The second time through the loop, all of the data on my plot disappears -- everything works fine if I don't include the <code>lines2d.set_xdata</code> line (other than the x-data points being wrong of course).  I've looked at the following posts:</p>
  
  <p><a href="https://stackoverflow.com/questions/4098131/matplotlib-update-a-plot">How to update a plot in matplotlib?</a></p>
  
  <p>and </p>
  
  <p><a href="https://stackoverflow.com/questions/11371255/update-lines-in-matplotlib">Update Lines in matplotlib</a></p>
  
  <p>However, in both cases, the user is only updating the <code>ydata</code> and I would like to update the <code>xdata</code> as well.</p>