Incorrect fill in graph objects when connectgaps is set to false
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
Whenever a graph object has the following parameters:
First series -> fill='tonexty',
Second series -> connectgaps=False
The fill connects the first point of this series with the first point of the last segment after "gaps" from the second series, instead of its respective first value.
Here is a basic example
import plotly.graph_objects as go
fig = go.Figure()
def remove_from_list(lst, idx):
return lst[:idx] + [None] + lst[idx+1:]
x = [i for i in range(5)]
y = [1 for _ in x]
fig.add_trace(go.Scatter(
x=x,
y=remove_from_list(y, 2),
connectgaps=False
))
y = [2 for _ in x]
fig.add_trace(go.Scatter(
x=x,
y=y,
fill='tonexty',
))
fig.show()
Here is another example with more than 1 gap in the data:
import plotly.graph_objects as go
fig = go.Figure()
def remove_from_list(lst, idx):
return lst[:idx] + [None] + lst[idx+1:]
x = [i for i in range(8)]
y = [1 for _ in x]
fig.add_trace(go.Scatter(
x=x,
y=remove_from_list(remove_from_list(y, 2), 5),
connectgaps=False
))
y = [2 for _ in x]
fig.add_trace(go.Scatter(
x=x,
y=y,
fill='tonexty',
))
fig.show()
I've also attached their respective figure outuputs.
Finally, I have an additional comment regarding how areas are filled.
The following shows another basic example with gaps in both series, and both with connectgaps=False.
import plotly.graph_objects as go
fig = go.Figure()
def remove_from_list(lst, idx):
return lst[:idx] + [None] + lst[idx+1:]
x = [i for i in range(5)]
y = [1 for _ in x]
fig.add_trace(go.Scatter(
x=x,
y=remove_from_list(y, 2),
connectgaps=False
))
y = [2 for _ in x]
fig.add_trace(go.Scatter(
x=x,
y=remove_from_list(y, 2),
fill='tonexty',
connectgaps=False
))
fig.show()
The connected area spans even the places where the values are undefined (during a gap). My expectation would be the opposite:
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定源文件或测试。首先运行提供的、使用 plotly.graph_objects 的 Python 示例,并比较 connectgaps=False 时 None 值周围渲染出的填充区域。当填充区域使用对应的系列片段且不会跨越未定义的间隙时,即视为完成;为所示案例添加回归覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100