plotly / plotly/plotly.py

Scattergl not drawing line with np.inf but only when in pd.Dataframe

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

还没有人认领这个 Issue。

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

描述

Hello,

I’m having a strange issue where a graph_objects Figure with Scatergl is not drawing anything if there is an np.inf in the series, but only if the data is coming from a Pandas Dataframe. The below code shows an example of the issue (See 3rd figure). This issue appears with 6.0.0 install in python.

import plotly.express as px
import plotly.graph_objects as go
import numpy as np
import pandas as pd

# Create a DataFrame with np.inf in a column
df = pd.DataFrame({
    'x': [0, 1, 2, 3, 4],
    'y': [0, 1, 4, 9, np.inf],
})

# Create a line plot  (Things are OK)
fig = px.line(data_frame=df, x='x', y='y', title='Looks OK')
fig.show()


# Create a line plot w/ Scatter  (Things are OK)
fig = go.Figure()
fig.add_trace(go.Scatter(
    x=df['x'],
    y=df['y'],
    mode='lines',
))
fig.update_layout(title=dict(text="Looks OK"),)
fig.show()


# Create a line plot w/ Scattergl  (Nothing shown on figure...)
fig = go.Figure()
fig.add_trace(go.Scattergl(
    x=df['x'],
    y=df['y'],
    mode='lines',
))
fig.update_layout(title=dict(text="Nothing displayed..."),)
fig.show()


# Create a line plot w/ Scattergl  (This is ok.... to_list fixes something?)
fig = go.Figure()
fig.add_trace(go.Scattergl(
    x=df['x'].to_list(),
    y=df['y'].to_list(),
    mode='lines',
))
fig.update_layout(title=dict(text="Looks OK"),)
fig.show()

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先使用 plotly 6.0.0 运行所提供的 Python 复现代码,并比较 Scatter、Scattergl 和转换为列表后的输入。当 Scattergl 能够与其他示例一致地渲染来自包含 np.inf 的 Pandas Series 的线时,该 issue 即完成。

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

评估

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

把新 issue 发到你的邮箱

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