How shall I draw "K" plot by matplotlib.finance for some special formate data as below?
<p>The codes are as below:</p>

<pre><code>import tushare as ts
import matplotlib.pyplot as plt
from matplotlib.finance import candlestick_ohlc as candle
stock=ts.get_hist_data('000581',ktype='w')
</code></pre>

<p>the data form of "stock" is as below picture:
<a href="http://i.stack.imgur.com/Bo7QU.png" rel="nofollow">enter image description here</a></p>

<p>Then the below codes:</p>

<pre><code>vals=stock.iloc[:,0:4]
fig=plt.figure()
ax=fig.add_subplot(111)
candle(ax,vals)
</code></pre>

<p>I get error as below:
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/anaconda3/lib/python3.5/site-packages/matplotlib/finance.py", line 735, in candlestick_ohlc
    alpha=alpha, ochl=False)
  File "/usr/local/anaconda3/lib/python3.5/site-packages/matplotlib/finance.py", line 783, in _candlestick
t, open, high, low, close = q[:5]
ValueError: not enough values to unpack (expected 5, got 4)</p>

<p>How shall I resove it?</p>

<p><code>candlestick</code> needs a very specific format <em>and</em> order to work. For example, if you use <code>_ohlc</code>, then the order must be open-high-low-close. The array for the candlestick graph can be prepared as follows:</p>

<pre><code>candleArray = []
while i &lt; len(datep):
    newLine = datep[i], openp[i], highp[i], lowp[i], closep[i], volumep[i], pricechange[i], pchange[i]
    candleArray.append(newLine)
    i += 1
</code></pre>

<p>Then, you can call candlestick with the array <code>candleArray</code>.</p>

python matplotlib