D3 - SVG线中的基线和线性插值之间的差异 [英] D3 - Difference between basis and linear interpolation in SVG line

查看:348
本文介绍了D3 - SVG线中的基线和线性插值之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实施了多系列折线图,比如由M. Bostock提供的,人们喜欢使用它作为插值函数,因为它平滑了极端峰值。当您对希望平滑变化但仅包含尖锐,不常采样的数据的内容进行建模时,此功能非常有用。这样的结果是,结果行不会连接所有数据点,改变极值的外观。



在你的情况下,尖峰是有趣的功能,异常到典型的0基线值。



下面是一个有趣的演示,演示不同类型的线插值:
http://bl.ocks.org/mbostock/4342190



您可以拖动数据,使其类似于您的尖峰,甚至可以单击添加新点。然后,切换到基本插值,并观看峰值平均值。




I implemented a multi-series line chart like the one given here by M. Bostock and ran into a curious issue which I cannot explain myself. When I choose linear interpolation and set my scales and axis everything is correct and values are well-aligned.

But when I change my interpolation to basis, without any modification of my axis and scales, values between the lines and the axis are incorrect.

What is happening here? With the monotone setting I can achieve pretty much the same effect as the basis interpolation but without the syncing problem between lines and axis. Still I would like to understand what is happening.

解决方案

The basis interpolation is implementing a beta spline, which people like to use as an interpolation function precisely because it smooths out extreme peaks. This is useful when you are modeling something you expect to vary smoothly but only have sharp, infrequently sampled data. A consequence of this is that resulting line will not connect all data points, changing the appearance of extreme values.

In your case, the sharp peaks are the interesting features, the exception to the typically 0 baseline value. When you use a spline interpolation, you are smoothing over these peaks.

Here is a fun demo to play with the different types of line interpoations: http://bl.ocks.org/mbostock/4342190

You can drag the data around so they resemble a sharp peak like yours, even click to add new points. Then, switch to a basis interpolation and watch the peak get averaged out.

这篇关于D3 - SVG线中的基线和线性插值之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆