title: Display realtime candlesticks using Python and Matplotlib on the same figure
body: <p>I would like to display realtime candlesticks chart using Python and Matplotlib</p>
  
  <p>I did this</p>
  
  <pre><code>#!/usr/bin/env python
  
  import time
  import matplotlib.pyplot as plt
  
  from matplotlib.pyplot import plot, draw, show
  from matplotlib.finance import candlestick
  from matplotlib.dates import date2num
  
  from numpy import nan
  import numpy as np
  
  fig = plt.figure()
  ax = fig.add_subplot(111)
  
  #plt.ion()
  #plt.ioff()
  
  while True:
  
      #plt.clf()
  
      #ax = plt.gca()
  
      opn =  104.04852126730329
      close = np.random.uniform(90, 110)
      high = max(opn, close)*np.random.uniform(1, 1.05)
      low = min(opn, close)*np.random.uniform(0.95, 1)
      DOCHLV = [[1, 100, 99, 101, 98, 0.0], [2, nan, nan, nan, nan, 0.0], [3, nan, nan, nan, nan, 0.0], [4, 104, 98, 105, 95, 0.0], [5, nan, nan, nan, nan, 0.0], [6, nan, nan, nan, nan, 0.0], [7, 100, 99.99976844819628, 100.91110690369828, 97.82248296015564, 1152.3258524820196], [8, 99.99976844819628, 100.51985544064271, 100.51985544064271, 96.65206230438159, 1578.5836411214814], [9, 100.51985544064271, 104.04852126730329, 104.54571702827914, 99.49632496479201, 1477.5651279091041], [10, opn, close, high, low, 372.6679262982206]]
      print(DOCHLV)
  
      #plt.close()
  
      fig = plt.figure()
      ax = fig.add_subplot(111)
  
      _ = candlestick(ax, DOCHLV, width=0.8, colorup='g', colordown='r', alpha=1.0)
      _ = ax.set_xlim(0, len(DOCHLV)+1)  
  
      #plt.show()
      plt.show(block=False)
  
      time.sleep(0.5)
  </code></pre>
  
  <p>Unfortunately candlesticks are drawn on several figures.</p>
  
  <p>Is there a way to fix this ?</p>
  
  <p>I tried to remove </p>
  
  <pre><code>    fig = plt.figure()
      ax = fig.add_subplot(111)
  </code></pre>
  
  <p>from while loop (in order to plot on the same ax)
  but chart is not updated</p>
  
  <p>I also tried to use plt.draw() instead of plt.show(...)
  but window doesn't appear</p>
  
  <p>I also tried to close (previous) window before plotting... but
  in such a case, chart is blinking.</p>