plotly / plotly/plotly.py

Bar yaxis range does not work with datetime

未關閉
#3,501 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug P3
主要語言
Python
星號
18.8k
分支
2.8k
平均合併
16 小時 26 分鐘
30 天內合併 PR
21

描述

Hello, I would like to use range with go.Bar and datetime.
From the docs https://plotly.com/python/reference/layout/yaxis/#layout-yaxis-range
I should provide range with start and end in str.

range=[str(datetime.time(hour=0)), str(datetime.time(hour=10))],

But what I get is this:

Screenshot 2021-12-06 at 11 38 26

The code:

    import plotly.graph_objects as go
    import datetime

    figure = go.Figure()
    figure.add_trace(
        go.Bar(
            x=x,
            y=y,
            legendgroup="duration",
            legendgrouptitle_text="Sleep",
            name="Sleep",
        )
    )
    
        figure.update_layout(
        xaxis=dict(
            title="Date",
            type="category",
        ),
        yaxis=dict(
            title="Time (hours)",
            type="date",
            tickformat="%H:%M",
            range=[0, str(datetime.time(hour=10))],
        ),
    )
    

The data:

>>> print(x)
['Nov 30 2021']

>>> print(y)
0   2021-12-06
Name: duration, dtype: datetime64[ns]

y is a pandas DataFrame

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先使用 go.Bar 和 figure.update_layout 從提供的 Python 重現開始,然後將 yaxis type、tickformat 和 range 的值與所引用的 yaxis 範圍文件進行比較。當 datetime y 軸接受所要求的界限,並在預期的 00:00–10:00 範圍內顯示長條時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
pandas, python
領域
data-visualization
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。