Skip to content

Using hour rangebreaks causes candlestick chart to fail #4795

Closed

Description

@AndrewSovik

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

Activity

  1. nicolaskruchten commented on Apr 30, 2020

    @nicolaskruchten
    Contributor

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

  2. added this to the v1.54.1 milestone on Apr 30, 2020
  3. added
    bug
    on Apr 30, 2020
  4. nicolaskruchten commented on Apr 30, 2020

    @nicolaskruchten
    Contributor

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

  5. archmoj commented on May 6, 2020

    @archmoj
    Contributor

    To me it looks like a duplicate of #4742.

  6. archmoj commented on May 6, 2020

    @archmoj
    Contributor

    Bug demo in JS.

  7. self-assigned this
    on May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions