I’m pretty new to Plotly and Python in general but is there a way to get the graph to remove gaps in a candlestick charts using bounds from a specific day and time to another? (Eg. Fri 21:00 to Sun 21:00) When I use rangebreaks bounded from sat to mon, it removes Fri 21:00 to Mon 0:00 (removing 3 hrs too much).
Also, when I rangebreak from Sat to Mon:
rangebreaks = dict(bounds=["sat", "mon"])
hover labels don’t show up for some reason but when I bound from [‘sat’, ‘sun’], the gaps are bigger but hover labels still appear.
[‘sat’, ‘mon’] (Hovering over data and nothing shows)
[‘sat’, ‘sun’] (Hover works but gaps are larger)
Also realized that when there are hover labels, candlestick width change w/ x axis when zoomed and they have a darker border around each candlestick:
vs. when there’s no hover (candlesticks have static width):
Code:
[code]import pandas as pd
import plotly as py
import plotly.graph_objs as go
df = pd.read_csv('Data/USDCAD15.csv', index_col=0, parse_dates=True, dayfirst=True) # import csv and automatically set Date as index
df.index.name = 'Date' # Set index name to Date
df.index = pd.to_datetime(df.index) # Convert datetime
df = df.drop_duplicates(keep=False) # Drop weekends
df_trunc = df.truncate(after=pd.Timestamp('2019-05-01'))
print(df_trunc)
layout = go.Layout(
xaxis=dict(rangebreaks=[
dict(bounds=["sat", "mon"]), # hide weekends
dict(values=["2015-12-25", "2016-01-01"]) # hide Christmas and New Year's
],
)
)
trace = go.Candlestick(x=df_trunc.index, open=df_trunc.Open, high=df_trunc.High, low=df_trunc.Low, close=df_trunc.Close,
name='Currency Quote')
data = [trace]
fig = go.Figure(data=data, layout=layout)
py.offline.plot(fig, filename='USDCAD.html')