Skip to content

Using hour rangebreaks causes candlestick chart to fail #4795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AndrewSovik opened this issue Apr 26, 2020 · 4 comments · Fixed by #4814
Closed

Using hour rangebreaks causes candlestick chart to fail #4795

AndrewSovik opened this issue Apr 26, 2020 · 4 comments · Fixed by #4814
Assignees
Labels
bug something broken
Milestone

Comments

@AndrewSovik
Copy link

Using an hour rangebreak, in my case {'pattern': 'hour', 'bounds': [16, 9.5]} (2nd last line) causes the candlestick chart to not plot open/close boxes and it breaks the hovering feature to preview data. There is also more space between points but I assumed that was because the lack of candle boxes.

Data:
data.xlsx

Code:
`import pandas as pd
from plotly.offline import plot
import plotly.graph_objects as go
from plotly.subplots import make_subplots

df = pd.read_excel('data.xlsx')

#Plot Chart
fig = make_subplots(
rows=2, cols=1,
subplot_titles=('Price', 'Volume'),
shared_xaxes=True,
vertical_spacing=0.3)
fig.add_trace(go.Candlestick( #Candlesticks
x=df['date'], open=df['open'], high=df['high'], low=df['low'], close=df['close']),
row=1, col=1)
fig.add_trace(go.Bar( #Volume
x=df['date'], y=df['volume'],
marker_color='blue'),
row=2, col=1,)
fig.update_layout(
title_text='AAPL Technical Analysis',
xaxis_rangeslider_visible=True,
showlegend=False)
fig.update_xaxes(
rangebreaks=[
{'pattern': 'day of week', 'bounds': [6, 1]}, #Break weekends
{'pattern': 'hour', 'bounds': [16, 9.5]}]) #Break after hours and market close

plot(fig)`

Remove {'pattern': 'hour', 'bounds': [16, 9.5]} to see correct candlesticks but I don't want to plot times where the market is after hours or closed.

Python 3.7.7, all modules are updated

Thanks

@nicolaskruchten
Copy link
Contributor

I'm going to move this to the Plotly.js repo, as this bug originates there.

@nicolaskruchten nicolaskruchten transferred this issue from plotly/plotly.py Apr 30, 2020
@nicolaskruchten nicolaskruchten added this to the v1.54.1 milestone Apr 30, 2020
@nicolaskruchten nicolaskruchten added the bug something broken label Apr 30, 2020
@nicolaskruchten
Copy link
Contributor

@archmoj I expect this is a duplicate of #4742 but I haven't had a chance to confirm.

@archmoj
Copy link
Contributor

archmoj commented May 6, 2020

To me it looks like a duplicate of #4742.

@archmoj
Copy link
Contributor

archmoj commented May 6, 2020

Bug demo in JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants