0
我想要使用Matplotlib.finance
庫和candlestick2
部分工作正常,繪製一些財務數據。然而`volume_overlay函數沒有在圖上顯示任何東西,儘管第二個軸正在被正確縮放。在matplotlib中添加音量覆蓋
還有類似的問題here但它不能解決問題,只是提供了一種創建自己的音量疊加的方法。
# Get data from CSV
data = pandas.read_csv('dummy_data.csv',
header=None,
names=['Time', 'Price', 'Volume']).set_index('Time')
# Resample data into 30 min bins
ticks = data.ix[:, ['Price', 'Volume']]
bars = ticks.Price.resample('30min', how='ohlc')
volumes = ticks.Volume.resample('30min', how='sum')
# Create figure
fig = plt.figure()
ax1 = fig.add_subplot(111)
# Plot the candlestick
candles = candlestick2(ax1, bars['open'], bars['close'],
bars['high'], bars['low'],
width=1, colorup='g')
# Add a seconds axis for the volume overlay
ax2 = ax1.twinx()
# Plot the volume overlay
volume_overlay(ax2, bars['open'], bars['close'], volumes, colorup='g', alpha=0.5)
plt.show()
任何人都可以告訴我我失蹤了什麼嗎?或者是volume_overlay
功能壞了?
EDIT
的數據從http://api.bitcoincharts.com/v1/trades.csv?symbol=mtgoxUSD下載 - 粘貼到記事本++,然後搜索並替換爲 「」 和 「\ n」 個。
作爲一個警告,該模塊會在不久得到一個主要的API改變未來https://github.com/matplotlib/matplotlib/pull/1920如果你真的使用這個模塊,請評論;) – tacaswell
,你可以發佈你正在使用的CSV? – tacaswell