Incorrect fill in graph objects when connectgaps is set to false
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by running the supplied Python examples with plotly.graph_objects and compare the rendered fills around None values when connectgaps=False. Done means fills use the corresponding series segments and do not span undefined gaps; add regression coverage for the shown cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100