Skip to content

y-values overlap when using rangebreaks  #2998

Open

Description

@user529481

picture of behavior: https://imgur.com/a/oSBgqvp

Screen Shot 2020-12-29 at 7 49 51 PM

I believe the same issue is experienced by another user here: https://community.plotly.com/t/rangebreaks-with-bounds-and-values-show-overlapping-candlesticks/46067

code to reproduce this:
(example.pkl can be found on https://repl.it/join/pdmlylnv-angstscheisse )

import pandas as pd
import plotly.graph_objects as go

df = pd.read_pickle('example.pkl')

fig = go.Figure(data=[go.Candlestick(x=df['time'], open=df['open'], high=df['high'], low=df['low'], close=df['close'])])

fig.update_xaxes(
    rangebreaks=[
        dict(bounds=[15, 9], pattern="hour"),
        # dict(bounds=["sat", "mon"]),
        dict(values=["2020-12-25"])
    ]
)
fig.show()

Activity

  1. fjafferi commented on Jun 14, 2021

    @fjafferi

    Any update on this? it seems the problem still exists.

  2. nicolaskruchten commented on Jun 14, 2021

    @nicolaskruchten
    Contributor

    I'm having trouble loading the pickle file... can someone provide a simple reproducible example of this please?

  3. fjafferi commented on Jun 14, 2021

    @fjafferi

    AAPL_1H.zip
    Here is a pickle file, I just tried with the code above and it seems okay. However, i was seeing the described behavior above yesterday. Let me reproduce and provide an example.

  4. fjafferi commented on Jun 14, 2021

    @fjafferi

    `import pandas as pd
    import plotly.graph_objects as go

    df = pd.read_pickle('AAPL_1H.pkl')

    fig = go.Figure(data=[go.Candlestick(x=df.index, open=df['open'], high=df['high'], low=df['low'], close=df['close'])])

    fig.update_xaxes(
    rangebreaks=[
    dict(bounds=[15, 9], pattern="hour"),
    # dict(bounds=["sat", "mon"]),
    dict(values=["2021-06-03"])
    ]
    )
    fig.show()`

    So it seems the problem appears to be when passing the dates list, and if the date falls within the x range.
    @nicolaskruchten
    Capture

  5. nicolaskruchten commented on Jun 15, 2021

    @nicolaskruchten
    Contributor

    @fjafferi Thanks for the zipfile but the problem is that I can't unpickle it :) Can you send me a CSV please?

  6. nicolaskruchten commented on Jun 29, 2021

    @nicolaskruchten
    Contributor

    OK, I found the time to get this file parsed. With Plotly.py 5.1 (powered by Plotly.js 2.2) I'm not seeing this behaviour any more:

    image

  7. nicolaskruchten commented on Jun 29, 2021

    @nicolaskruchten
    Contributor

    Ah but when uncomment the weekend exclusion I do see a problem:

    image

    I've logged the issue in the underlying Javascript library as plotly/plotly.js#5783

  8. Lucasdesard commented on May 15, 2023

    @Lucasdesard

    I had the exact same problem and fixed it in the following way: I changed the order of the arguments that I passed to the function such as in the following example:
    fig.update_xaxes(
    rangebreaks=[
    dict(values=["2022-12-25"]), # hide holidays (Christmas and New Year's, etc)
    dict(bounds=["sat", "mon"]), # hide weekends, eg. hide sat to before mon
    dict(bounds=[18, 6], pattern="hour") # hide hours outside of 6pm-6am
    ]
    )

  9. jinseo99 commented on Feb 1, 2024

    @jinseo99

    I am having similar issue as well.
    For me the issue is when the holiday and weekend are in consecutive order.

    There's two cases:

    1. Sat, Sun, Mon (Holiday)
    2. Fri (Holiday), Sat, Sun.

    It seems the reordering of the rangebreaks arguments fixes them but only conditionally.

    For example for case 1:
    The following order works:

    dict(values=["2023-05-29"]), # hide holiday that is Monday
    dict(bounds=["sat", "mon"]), # hide weekends
    

    and the following causes a bug and shows y-value overlaps:

    dict(bounds=["sat", "mon"]), # hide weekends
    dict(values=["2023-05-29"]), # hide holiday that is Monday
    

    This occurs reversely for case 2:
    The following order works:

    dict(bounds=["sat", "mon"]), # hide weekends
    dict(values=["2023-04-07"]), # hide holiday that is Friday
    

    and the following causes a bug and shows y-value overlaps:

    dict(values=["2023-04-07"]), # hide holiday that is Friday
    dict(bounds=["sat", "mon"]), # hide weekends
    
  10. Coding-with-Adam commented on Feb 5, 2024

    @Coding-with-Adam
    Contributor

    hi @jinseo99
    Thanks for reporting. This seems related to the plotly.js #5783 issue

    I've updated the priority of that bug.

  11. self-assigned this
    on Jul 8, 2024
  12. removed their assignment
    on Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions