Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong interaction between fill:tonexty and fill:none traces #113

Closed
iustin opened this issue Dec 14, 2015 · 7 comments
Closed

Wrong interaction between fill:tonexty and fill:none traces #113

iustin opened this issue Dec 14, 2015 · 7 comments

Comments

@iustin
Copy link

iustin commented Dec 14, 2015

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.

@etpinard
Copy link
Contributor

@iustin Thanks for writing in. This is an interesting report.

@alexcjohnson will share more information on the fill-to algorithm shortly.

@alexcjohnson
Copy link
Collaborator

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
}

@iustin
Copy link
Author

iustin commented 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 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.

@alexcjohnson
Copy link
Collaborator

@iustin

I'mnot sure what's the difference between the low trace (fill:none) and my no-fill trace (also fill:none).

high low 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?

@iustin
Copy link
Author

iustin commented 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-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.

@etpinard
Copy link
Contributor

Maybe fixed by #3005

@gvwilson
Copy link
Contributor

gvwilson commented 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

@gvwilson gvwilson closed this as completed Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants