I'm trying to plot some financial data using Matplotlib.finance
library and the candlestick2
part is working fine. However the `volume_overlay function is not showing anything on the plot, although the second axis is being scaled correctly.
There's a similar question here but it doesn't resolve the issue, just provides a way of creating your own volume overlay.
# 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()
Can anyone show me what I'm missing? Or is the volume_overlay
function broken?
EDIT
The data is downloaded from http://api.bitcoincharts.com/v1/trades.csv?symbol=mtgoxUSD - pasted into Notepad++ and then search and replaced " " with "\n".