1
fig_2 = plt.figure(figsize=(16,6))

axes2 = fig_2.add_axes([0,0,1,1])

axes2.plot(tesla_df['Volume'])
axes2.plot(gm_df['Volume'])
axes2.plot(ford_df['Volume'])

plt.legend(['Tesla','GM','Ford'])

axes2.xaxis.set_minor_locator(dates.MonthLocator())
axes2.xaxis.set_minor_formatter(dates.DateFormatter('%m--%Y'))

How can I make the dates on my chart appear every 6 months on the x axis instead of every month?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
cal17_hogo
  • 129
  • 2
  • 13
  • [How to make good reproducible pandas examples?](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Parfait Nov 26 '18 at 23:35

1 Answers1

4

You would specify the months to tick in the initialization of the MonthLocator. So for the months January and July

matplotlib.dates.MonthLocator((1,7))

If you don't care about which months to tick, you can also specify the interval

matplotlib.dates.MonthLocator(interval=6)
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712