Incorrect fill rendering caused by gaps in data · Issue #2736 · plotly/plotly.js · GitHub
Skip to content

Incorrect fill rendering caused by gaps in data #2736

Open

Description

@acarapetis

I'm using Plotly.js to display some time series data with the following relevant properties:

  • Large gaps in the data, and
  • Non-symmetric uncertainty (i.e. each data point has min,avg,max values).

I'm attempting to plot this by adapting this example, but I seem to have come across a bug: when using data with gaps (and connectgaps: false) at the same time as fill: 'tonexty', the gaps cause the fill to be drawn incorrectly:
screenshot from 2018-06-14 15-28-40

(The section of data at the very end of the graph is rendered correctly, but everything before the last gap is messed up.) For a simple example that reproduces this issue, see this codepen.

Interestingly, adding fill: 'tozeroy' to the bottom trace seems to resolve the obviously broken aspect of this issue:
screenshot from 2018-06-14 15-39-04

I would still argue that the expected behaviour is that connectgaps: false should result in no fill crossing the gaps.

Activity

  1. changed the title [-]Gaps in data break filled areas[/-] [+]Incorrect fill rendering caused by gaps in data[/+] on Jun 14, 2018
  2. alexcjohnson commented on Jun 14, 2018

    @alexcjohnson
    Collaborator

    Confirmed, thanks @acarapetis - and the pared-down codepen is much appreciated! Seems to be a problem specifically with gaps in the lower trace.

    I'm probably going to need to muck with fills for #1217, perhaps I can fix this at the same time (along with the many other fill bugs)

  3. yarl commented on Jul 31, 2018

    @yarl

    We have similar similar issue with two data series that should look like one, continuous data series. We use fill: 'tozeroy', one series ends with many nulls, one series starts with many nulls.

    Effect as shown below:

    screenshot 2018-07-31 15 21 11

  4. nickrussler commented on Nov 29, 2019

    @nickrussler

    I encountered a similar problem and as @acarapetis mentioned adding fill: 'tozeroy' to the bottom trace mitigated the problem for me in combination with fillcolor: 'transparent' for the bottom trace. Also mapping the null values to some very small number (-99999999) to "pinch" the area off worked for me.

  5. jhannink commented on Apr 24, 2020

    @jhannink

    Any update on this issue in the meantime?

    I encountered a similar problem and as @acarapetis mentioned adding fill: 'tozeroy' to the bottom trace mitigated the problem for me in combination with fillcolor: 'transparent' for the bottom trace. Also mapping the null values to some very small number (-99999999) to "pinch" the area off worked for me.

    The workaround above does somehow mitigate the problem. However, the gaps are also filled:
    grafik
    Any idea on how to avoid that?

  6. leoyala commented on May 10, 2023

    @leoyala

    I was wondering if there is an update regarding this bug. I am still facing this issue in plotly==5.14.1

  7. Noahkoole commented on Dec 29, 2023

    @Noahkoole

    I am also having this issue still, any update on this?

  8. Brax94 commented on Feb 19, 2024

    @Brax94

    We are also experiencing this issue. The fill options does not respect gaps, and will fill across them.
    We have been using a workaround for a while, which is basically to add a graph for each continuous part of the data.

    Is anyone looking in on this?

  9. faebebin commented on Feb 28, 2024

    @faebebin

    Same problem here using fill="tonexty" to fill between to lines with data gaps being unwillingly filled.

    Using plotly-python on plotly==5.18.0

  10. wbeardall commented on Apr 2, 2024

    @wbeardall

    Is there any progress on this?

  11. self-assigned this
    on Jun 11, 2024
  12. removed their assignment
    on Aug 2, 2024
  13. Apflkuacha commented on Feb 5, 2025

    @Apflkuacha

    Hmm, an open issue from 2018.. It also occures on simple data like it could be seen here, there are "null" measurements in between. The lines are printed correctly with the gaps but the filled area is connected:

    Image

    I would expect this, the area is not drawn when there are no values (null) like the line which is not drawn

    Image

  14. walkermchugh commented on Oct 21, 2026

    @walkermchugh

    Related plotly.py report: plotly/plotly.py#5632

    I reproduced the tozeroy gap with x: [0, 1, 2, 3, 4], y: [2, 2, null, 2, 2], and connectgaps: false. The SVG scatter renderer separates the line segments, but joins them into one fill path. That path paints the missing span.

    I propose closing each valid segment against the zero axis as its own fill subpath for tozeroy and tozerox. connectgaps: true would retain one continuous fill. A review branch includes the code and a Jasmine regression test: walkermchugh/plotly.js@main...codex/fix-tozero-fill-gaps-5632. The existing scatter_fill_corner_cases image mock covers gaps.

    This proposal covers SVG scatter to-zero fills. It does not resolve the tonexty or scattergl cases in this broader issue. I will wait for human code review before opening a draft PR.

  15. camdecoster commented on Oct 21, 2026

    @camdecoster
    Contributor

    Thanks for looking into this. Our team will review your report and follow up.

  16. scenerecap commented on Oct 22, 2026

    @scenerecap

    Still reproduces on Plotly.js 4.1.2 (cdn.jsdelivr.net, 2026-10-22, headless Chromium 151).

    Steps:

    1. Create a scatter trace: x: [0,1,2,3,4], y: [2,2,null,2,2], fill: 'tozeroy', connectgaps: false
    2. Render with Plotly.newPlot

    Expected: fill area stops at each side of the null — two separate filled segments (indices 0–1 and 3–4).
    Actual: the line correctly breaks at x=2, but the SVG fill path continues across the gap as one closed region, painting the span from x=1 to x=3 solid.

    A side-by-side control trace (y: [2,2,2,2,2], no nulls) fills correctly to y=0.

    Recording of both traces rendered together: https://scenerecap.com/s/nwd1gul2xp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2considered for next cyclebugsomething brokensize: 3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions