I'm trying to exclude non-business hours AND weekends from the line chart, but it's not working using the following data:
The data:
The code to plot the line chart:
fig = px.line(df, x=df.index, y='close')
fig.update_xaxes(rangebreaks=[dict(bounds=[16, 9.5], pattern="hour"),
dict(bounds=['sat', 'mon'])])
fig.show()
The Output of the line chart:
If I use another type of data, this works, like the example of this link: https://plotly.com/python/time-series/
import plotly.express as px
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig = px.scatter(df, x='Date', y='AAPL.High', range_x=['2015-12-01', '2016-01-15'],
title="Hide Weekend and Holiday Gaps with rangebreaks")
fig.update_xaxes(
rangebreaks=[
dict(bounds=["sat", "mon"]), #hide weekends
dict(values=["2015-12-25", "2016-01-01"]) # hide Christmas and New Year's
]
)
fig.show()