plotly / plotly/plotly.py

Incorrect fill in graph objects when connectgaps is set to false

オープン
#5,105 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P2
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
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()

Image

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()

Image

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:
Image

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ソースファイルやテストは指定されていません。まず、提供されている plotly.graph_objects を使った Python の例を実行し、connectgaps=False の場合に None 値の周囲で描画される塗りつぶしを比較してください。塗りつぶしが対応する系列セグメントを使用し、未定義のギャップをまたがないことを確認できれば完了です。示されているケースのリグレッションカバレッジを追加してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。