Skip to content

Spline interpolation for line charts and scatter plots is limited and distorts data #2085

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

Closed
Animus451 opened this issue Oct 12, 2017 · 2 comments

Comments

@Animus451
Copy link

Animus451 commented Oct 12, 2017

Currently, the spline technique that is employed for line charts and scatter plots seems to be some form of non-monotonic polynomial regression. Whatever method is used to generate the spline often distorts the data set to which the curve is being fit. (See below) The graph below shows false extrema as a result of the spline.
innacurate splining
While this kind of spline may work for some situations, a more generally useful spline would be a monotonic polynomial regression. This specifically prevents distorted representations of extrema.

Note: A similar issue has been opened here: #993

@rreusser
Copy link
Contributor

rreusser commented Oct 12, 2017

A good suggestion! Current behavior is actually 2D catmull-rom splines. That means there's no favored independent variable or axis. Which in turn means, I guess, monotonic with respect to what? Which then means this would perhaps take the form of shape: 'spline' | 'monotonicx' | 'monotonicy'. Or shape: 'spline', monotonic: false | 'x' | 'y', though the latter makes the 'smoothing' parameter unused for that case, which is just a bit awkward.

Paths are computed for use here and step paths (perhaps most similar to this case) are computed here. It would then be a matter of computing a monotonic path (in screen coordinates, I believe). The math is here.

It certainly seems reasonable and perhaps not even that difficult, though I don't believe it's currently on the radar. A PR would be gladly accepted though. Glad to help think it through, otherwise those are my thoughts on what it would take.

@alexcjohnson
Copy link
Collaborator

Thanks for pointing to #993 - it is indeed a duplicate, lets keep the discussion contained over there.

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

3 participants