Plotting a line graph with scale.quantile()

别等时光非礼了梦想. 提交于 2019-12-13 06:35:45

问题


I am trying to plot a sorted array of normally distributed data so that it plots as straight line. I would like to do this using a cumulative density function, which I think is also known as a quantile function. Unfortunately, I haven't found many examples that use the quantile scale.

Here is my attempt to use the quantile scale: http://jsfiddle.net/tbcholla/hmFqJ/3/. I set up my x scale this way:

var x = d3.scale
    .quantile()
    .range(d3.range(0,width,1))//this will create an array from 0 to the width, counting by 1's.
    .domain([0,simple.length]);

and drew my line this way:

var rank = 0;
var myLine = d3.svg.line().interpolate("step-before")
    .x(function(d) {
        rank = rank +1;
        return x(rank);})
    .y(function(d) {
        return y(d);
});

Can anyone help explain where I am going wrong plotting the quantile scale? Can the quantile scale be used as a cumulative density function? Are there any examples of this scale in use that you could point me towards?

来源:https://stackoverflow.com/questions/17758823/plotting-a-line-graph-with-scale-quantile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!