How to skip empty dates (weekends) in a financial Matplotlib Python graph?

Eric the Red picture Eric the Red · Aug 13, 2009 · Viewed 25.4k times · Source
ax.plot_date((dates, dates), (highs, lows), '-')

I'm currently using this command to plot financial highs and lows using Matplotlib. It works great, but how do I remove the blank spaces in the x-axis left by days without market data, such as weekends and holidays?

I have lists of dates, highs, lows, closes and opens. I can't find any examples of creating a graph with an x-axis that show dates but doesn't enforce a constant scale.

Answer

idrinkpabst picture idrinkpabst · Feb 25, 2010

There's an example of how to do this on the Matplotlib site:

https://matplotlib.org/gallery/ticks_and_spines/date_index_formatter.html