plotly / plotly/plotly.py

Bar chart with timeseries index not displaying depending on proximity of the times

未关闭
#2,987 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

Found an issue causing a bar chart to display nothing when displaying timeseries data. It seems to be caused by having stacked data at two points which are very close in time (e.g. 12:00:00 and 12:00:01) and then one point much further away (e.g. 17:00:00).

import pandas as pd
import plotly.express as px

times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:01']  
#times = ['2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00', '2020-12-18 02:15:00'] <-- works
vals = [10, 50, 20, 350, 250]

# Uncomment to cause bar chart to display no data
# times.append('2020-12-18 13:00:00')
# vals.append(1)
  
df = pd.DataFrame(list(zip(times, vals)), 
               columns =['DT', 'Val']) 

df['DT'] = pd.to_datetime(df['DT'])

df = df.set_index('DT')
fig = px.bar(df, x=df.index, y=df['Val'])

fig.show()
  • The code unchanged displays the figure fine
    1
  • If you uncomment the two append lines, adding in a data point which is further away, then the figure is empty
    2
  • If you uncomment the two append lines and changes the initial times list so that they are all :00, the figure displays fine
    3

Therefore it seems to be caused by having points at 02:15:00 / 02:15:01 and then a point much later at 13:00:00

Thanks

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先运行该 issue 的 pandas 和 Plotly Express 复现,先使用相近的时间戳,然后添加 13:00:00 这一数据点。在两种情况下比较生成的 figure 数据或渲染结果;当柱状图能够在失败的情况下显示所提供的时间序列数据,同时不破坏正常工作的示例时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
pandas, plotly, python
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。