You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong interaction between fill:tonexty and fill:none traces #113
Not sure if I'm misunderstanding the way fill should be used or not. In any case, a scatter graph with:
a few fill none lines, which might or might not intersect the fill lines, which have to come first
one fill tozeroy and multiple tonexty lines; none of these fill-something lines are intersecting
Everything looks OK, until one hides the tozeroy line and all tonexty lines that have values smaller than the non-fill lines. Normally I'd expect the next 'fill-something' line to expand to zero, but - since there is a hard separation between tozeroy and tonexty - this doesn't happen. Instead, the next (and smallest) fill-tonexty line will just fill to a non-fill line.
If there are no non-fill lines, then the smalles tonexty line will - as expected - fill to zeroy. It seems to me that tonexty should ignore fill:none lines, or alternatively: remove the distinction between tonexty and tozeroy, since tonexty already does tozeroy if it doesn't find a next y trace.
I'm not sure I explained correctly, so here's a chart that shows this behaviour: https://plot.ly/~iustin/59/no-fill-fill-1-fill-2-fill-3/
just hide/unhide the fill-1 trace, and see the wrong behaviour. Additionally toggle the no-fill trace as well. If on the other hand, fill-2 is hidden, you can see that fill-3 fills correctly to fill-1, and not to no-fill, so sometimes fill:none traces are indeed ignored.
Oh interesting indeed... I hadn't thought about what should happen with fill when you hide traces but this definitely is NOT it. Good catch. This is I believe the only case we have, at least so far, where the attributes of a hidden trace should still matter!
I think the right logic is to chain tonext across hidden scatter traces until you reach a scatter trace that's either visible or some other fill, NOT tonext, or you reach the beginning. That way you'll always fill to the same endpoint as when all traces are visible, except when that endpoint is itself hidden in which case you don't fill at all. Lets look at two cases:
your plot, ie a stack that starts at zero with an unfilled trace before it: hide fill-1, and fill-2 currently fills to no-fill. With this new rule fill-2 looks at fill-1, sees hidden fill:tozero and inherits it, so your stack still fills to zero. If you hide fill-1 AND fill-2, then fill-3 looks at fill-2, sees hidden fill:tonext and keeps looking; it looks at fill-1 and sees hidden fill:tozero and inherits it, so your stack (which is now only fill-3 still fills to zero.
two traces low and high, filled between to make a confidence band, and you hide the first one (low). Right now we would fill from high either to some other earlier trace (if there is a visible scatter trace before it) or to zero. With this new rule, high would look at low, see fill:none, and inherit it, so the fill disappears entirely, regardless of what comes before it
So to be precise, lets say trace i is your fill:tonext trace: (but to be imprecise I'm not sure where we can use fullData vs data for invisible traces so this pseudocode ignores that...)
filli=tracei.fill;for(j=i;j>=0;j--){tracej=data[j];if(tracej.type!=='scatter')continue;if(tracej.visible!==true)break;// recall visible='legendonly'...if(trace.fill.substr(0,6)!=='tonext'){filli=tracej.fill;break;}// what's left to continue looping is only invisible scatter fill:tonext traces}
One question: in your example, I'mnot sure what's the difference between the low trace (fill:none) and my no-fill trace (also fill:none). It sounds like in the first example, you ignore no-fill's fill:none and keep searching for the eventually found fill:tozero, but in the second example you take the first found fill:none trace. I'm not actually sure if the semantics of just 3 possibilities (none, zero, next) are actually enough - maybe we need an extra nextany? in my example, I only want fill:tonext to mean fill:tonextfill, in your example you want fill:tonextany.
I'mnot sure what's the difference between the low trace (fill:none) and my no-fill trace (also fill:none).
highlow I'm thinking of things like confidence bands - which eventually plotly will have as an option for displaying error bars... but for now a plot like this has three line traces (and one trace of points). low is the bottom of the band, and has fill:none, and high is the next trace, with fill:tonext - if you hide low, I'd argue, the fill should disappear. That is exactly what would happen if high inherits the fill:none from the hidden low. It would never inspect the center trace or the data points, regardless of whether these come before or after the band in the trace list.
@etpinard perhaps one of you guys can flesh out the above algorithm, then make a few tests (side-by-side subplots with all the traces visible on one side, some turned off on the other?) so we can see if we all agree that this is doing the right thing?
@alexcjohnson - ah, I understood what confidence bands are; what I meant was: I don't see how with the current options, you can make a difference between somebody doing a confidence band, and somebody (like my example) who wants fill-2 to extend to zero if fill-1 is hidden while also having a no-fill (which no-fill I gues is similar to the 3rd trace in the confidence band example). I guess I'm missing something, so I'll patiently wait for your fix, no hurry.
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson
Activity
etpinard commentedon Dec 15, 2015
@iustin Thanks for writing in. This is an interesting report.
@alexcjohnson will share more information on the fill-to algorithm shortly.
alexcjohnson commentedon Dec 15, 2015
Oh interesting indeed... I hadn't thought about what should happen with fill when you hide traces but this definitely is NOT it. Good catch. This is I believe the only case we have, at least so far, where the attributes of a hidden trace should still matter!
I think the right logic is to chain
tonextacross hidden scatter traces until you reach a scatter trace that's either visible or some other fill, NOTtonext, or you reach the beginning. That way you'll always fill to the same endpoint as when all traces are visible, except when that endpoint is itself hidden in which case you don't fill at all. Lets look at two cases:fill-1, andfill-2currently fills tono-fill. With this new rulefill-2looks atfill-1, sees hiddenfill:tozeroand inherits it, so your stack still fills to zero. If you hidefill-1ANDfill-2, thenfill-3looks atfill-2, sees hiddenfill:tonextand keeps looking; it looks atfill-1and sees hiddenfill:tozeroand inherits it, so your stack (which is now onlyfill-3still fills to zero.lowandhigh, filled between to make a confidence band, and you hide the first one (low). Right now we would fill fromhigheither to some other earlier trace (if there is a visible scatter trace before it) or to zero. With this new rule,highwould look atlow, seefill:none, and inherit it, so the fill disappears entirely, regardless of what comes before itSo to be precise, lets say trace
iis yourfill:tonexttrace: (but to be imprecise I'm not sure where we can use fullData vs data for invisible traces so this pseudocode ignores that...)iustin commentedon Dec 15, 2015
@alexcjohnson I'm glad you found this interesting!
One question: in your example, I'mnot sure what's the difference between the
lowtrace (fill:none) and myno-filltrace (alsofill:none). It sounds like in the first example, you ignore no-fill'sfill:noneand keep searching for the eventually foundfill:tozero, but in the second example you take the first foundfill:nonetrace. I'm not actually sure if the semantics of just 3 possibilities (none, zero, next) are actually enough - maybe we need an extranextany? in my example, I only wantfill:tonextto meanfill:tonextfill, in your example you wantfill:tonextany.alexcjohnson commentedon Dec 16, 2015
@iustin
highlowI'm thinking of things like confidence bands - which eventually plotly will have as an option for displaying error bars... but for now a plot like this has three line traces (and one trace of points).lowis the bottom of the band, and hasfill:none, andhighis the next trace, withfill:tonext- if you hidelow, I'd argue, the fill should disappear. That is exactly what would happen ifhighinherits thefill:nonefrom the hiddenlow. It would never inspect the center trace or the data points, regardless of whether these come before or after the band in the trace list.@etpinard perhaps one of you guys can flesh out the above algorithm, then make a few tests (side-by-side subplots with all the traces visible on one side, some turned off on the other?) so we can see if we all agree that this is doing the right thing?
iustin commentedon Dec 16, 2015
@alexcjohnson - ah, I understood what confidence bands are; what I meant was: I don't see how with the current options, you can make a difference between somebody doing a confidence band, and somebody (like my example) who wants
fill-2to extend to zero iffill-1is hidden while also having ano-fill(whichno-fillI gues is similar to the 3rd trace in the confidence band example). I guess I'm missing something, so I'll patiently wait for your fix, no hurry.etpinard commentedon Sep 14, 2018
Maybe fixed by #3005
gvwilson commentedon Jun 5, 2024
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson