plotly / plotly/plotly.py

JupyterDash line shapes incorrect plotted

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

还没有人认领这个 Issue。

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

描述

Plotting lines in Plotly and JupyterDash gives a problem. I don't know if the issue is related to Plotly or JupyterDash, depending on which is the expected behaviour.

It did work in a previous version of Plotly.

Versions:

dash==1.17.0
jupyter-dash==0.3.1
plotly==4.12.0

import plotly.graph_objects as go
from dash.dependencies import Input, Output
from jupyter_dash import JupyterDash

from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
import dash_table

x_data = [ 54135, 12346, 75492, 64135, 748612, 31548 ]

fig = go.Figure(go.Scatter(x=x_data, y=[1, 2, 3, 4, 5, 6]))
fig.update_xaxes(
        title_text='Segments',
        type='category'
)
fig.add_shape(
      dict(
        type="line",
        xref='x', yref='y',
        x0=x_data[4], x1=x_data[4],
        y0=0, y1=10,
      )
)
fig.show()

app = JupyterDash(__name__)

app.layout = html.Div([
    dcc.Graph(figure=fig)
])

app.run_server(host='0.0.0.0', port=8003)

But apparently, this gives different results in Plotly as it does in Dash.

Plotly
image

Dash
image

(The small part on the left is the zoomed-out result, because the vertical-line was plotted at 31548 (which is the class of the X_data, but Dash seems to regard is as an integer)
This only happened in the latest updates (I used to work with plotly=4.8.0 before this error)

贡献指南

打开贡献指南

从这里开始

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

调研方向

从提供的 Python 复现开始,使用所列出的 Plotly、Dash 和 JupyterDash 版本,比较 fig.show() 与 JupyterDash app.run_server() 的输出。跟踪添加的 shape 对应的分类 x 轴值是如何被解释的,然后确定该差异属于 Plotly 还是 JupyterDash。当垂直线在两种输出中都与预期的类别对齐时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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