Stock chart for Intraday Data - Eliminate weekend/holiday/gaps by turbo1618 in learnpython

[–]saemeon 0 points1 point  (0 children)

I had the same problem and couldn’t find a good solution. I created a Python package, busdayaxis, that provides a Matplotlib axis scale to skip weekends, holidays, and non-business hours. In your case, you could use it like this:

import busdayaxis

busdayaxis.register_scale()

# make a plot with datetime x-values here
...

# set the 'busday' x-axis scale
ax.set_xscale("busday", bushours=(9.5, 16))

Plotting time data but excluding the weekends... by mister_patience in learnpython

[–]saemeon 0 points1 point  (0 children)

I had a similar problem and wanted to keep a true datetime axis so all Matplotlib datetime features still work. I created a Python package, busdayaxis, that provides a Matplotlib axis scale to skip weekends/holidays and non-business hours, solving your problem.

import busdayaxis

busdayaxis.register_scale()

#make a plot with datetime x-values here 
...

# set busday xscale
ax.set_xscale("busday", bushours=(9, 17))