0

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()

Resulting plot

I also have issues with the volume overlay layout, but that has to be put under a separate question, if I'm not mistaken.

EFL
  • 938
  • 4
  • 11
  • 23
  • See here: http://matplotlib.org/examples/api/date_index_formatter.html – tmdavison Sep 09 '16 at 09:40
  • Or [here](http://stackoverflow.com/questions/1273472/how-to-skip-empty-dates-weekends-in-a-financial-matplotlib-python-graph), [here](http://stackoverflow.com/questions/10529492/how-do-i-plot-only-weekdays-using-pythons-matplotlib-candlestick) or [here](http://stackoverflow.com/questions/35397562/matplotlib-only-business-days-without-weekends-on-x-axis-with-plot-date) – tmdavison Sep 09 '16 at 09:41
  • Thanks for the response, @tom. However, none of the links seem to have the answer. The problem is that if i do not put he volume overlay, the problem on the weekends is addressed. however, if I add the volume overlay, the date issue, wherein weekends are plotted, appears. BTW, I accidentally pressed the "yes" to a duplicate. How do I undo the error? – EFL Sep 09 '16 at 14:24

0 Answers0