I cannot seem to figure out how to fix the x-axis wherein the weekend dates are automatically removed. Before I added the volume overlay (mfin.volume_overlay3()
) on the candlestick plot (mfin.candlestick_ohlc()
), the weekends was recognized and removed from the plot; that is, you won't see a gap between trading days. However, after I add the volume overlay, the x-axis suddenly has data gaps (weekends).
I provide the code below where quotes_df
is a pandas data frame of a stock quote with column names: Date, Open, High, Low, Close, and Volume, respectively.
import matplotlib.finance as mfin
plt.figure(figsize=(12,8))
ax1 = plt.gca()
_ = mfin.candlestick_ohlc(ax1, quote_df.values.tolist(), width=0.6)
ax1.set_ylim(90,110)
ax1.xaxis_date()
ax1.set_ylabel("Price")
ax2 = ax1.twinx()
ax2.set_ylim(0,50000000)
_ = mfin.volume_overlay3(ax2, quote_df.values.tolist(),
colorup='k', colordown='r', width=4, alpha=1.0)
ax2.set_ylabel("Volume")
plt.show()
I also have issues with the volume overlay layout, but that has to be put under a separate question, if I'm not mistaken.