plotly / plotly/plotly.py

fail to update_xaxes rangebreaks by datetime

Open
#3,224 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

data df:
`
id date_time time_hms time_second price time_date

0 2021-05-31 09:25:00 09:25:00 33900 7 2021-05-31

1 2021-05-31 09:30:00 09:30:00 34200 8 2021-05-31

2 2021-05-31 09:30:01 09:30:01 34201 7 2021-05-31

3 2021-05-31 09:30:02 09:30:02 34202 6 2021-05-31

4 2021-05-31 09:30:03 09:30:03 34203 5 2021-05-31

... ... ... ... ...

24264 2021-06-04 14:56:56 14:56:56 53816 7 2021-06-04

24265 2021-06-04 14:56:57 14:56:57 53817 6 2021-06-04

24266 2021-06-04 14:56:58 14:56:58 53818 4 2021-06-04

24267 2021-06-04 14:56:59 14:56:59 53819 7 2021-06-04

24268 2021-06-04 15:00:00 15:00:00 54000 8 2021-06-04
`

code:
`
import pandas as pd
import plotly.express as px
import plotly.io as pio

    fig = px.line(df,
                  x = "date_time",
                  y = "price"
                )

    fig.update_xaxes(
        rangebreaks=[
            dict(bounds=["2021-06-01 09:25:00", "2021-06-04 09:25:01"])  # hide by datetime
        ]
    )

    pio.write_html(fig, file="stock_graph_px.html", auto_open=True)

`

the result html page is blank.

as document, rangebreaks only work for "date" .

but, how to deal with datetime breaks?

is there a simple way to set axis datetime breaks?

plotly==4.14.3
Python 3.8.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied pandas, Plotly Express, and pio.write_html example with Plotly 4.14.3, then inspect how update_xaxes handles the datetime rangebreak bounds. Confirm the failure and determine whether datetime breaks should produce a nonblank HTML page; validate the result with the same reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.