def candlestick(ax, quotes, width=0.2, colorup='k', colordown='r', alpha=1.0):
 OFFSET = (width / 2.0)
 lines = []
 patches = []
 for q in quotes:
  (t, open, close, high, low) = q[:5]
  if (close >= open):
   color = colorup
   lower = open
   height = (close - open)
  else:
   color = colordown
   lower = close
   height = (open - close)
  vline = Line2D(xdata=(t, t), ydata=(low, high), color='k', linewidth=0.5, antialiased=True)
  rect = Rectangle(xy=((t - OFFSET), lower), width=width, height=height, facecolor=color, edgecolor=color)
  rect.set_alpha(alpha)
  lines.append(vline)
  patches.append(rect)
  ax.add_line(vline)
  ax.add_patch(rect)
 ax.autoscale_view()
 return (lines, patches)

def candlestick ( ax , quotes , width = 0.2 , colorup = 'k' , colordown = 'r' , alpha = 1.0 ) : OFFSET = ( width / 2.0 ) lines = [ ] patches = [ ] for q in quotes : ( t , open , close , high , low ) = q [ : 5 ] if ( close >= open ) : color = colorup lower = open height = ( close - open ) else : color = colordown lower = close height = ( open - close ) vline = Line2D ( xdata = ( t , t ) , ydata = ( low , high ) , color = 'k' , linewidth = 0.5 , antialiased = True ) rect = Rectangle ( xy = ( ( t - OFFSET ) , lower ) , width = width , height = height , facecolor = color , edgecolor = color ) rect . set_alpha ( alpha ) lines . append ( vline ) patches . append ( rect ) ax . add_line ( vline ) ax . add_patch ( rect ) ax . autoscale_view ( ) return ( lines , patches )
quotes is a list of tuples .