统计汇总数据中的绘图箱图 [英] Ploting box plot from statistical summary data

查看:97
本文介绍了统计汇总数据中的绘图箱图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的页面上添加一个箱形图.类似于(使用Plotly.js).

I would like to add a box plot to my page. Something like this (using Plotly.js).

在上面的链接中实现示例的问题是plotly.js库期望所有点,而我只能访问已经计算出的统计数据.换句话说,我想通过传递maxminmedavrstdev(系列的统计数据)而不是所有数据点本身来绘制图形.

The problem with implementing the example from the link above is that the plotly.js library expect all the points, whereas I only have access to the already computed statistical data. In other words, I would like to plot the graphic by passing max, min, med, avr, stdev (statistical data of the series) instead of all the data points themselves.

P.s .:不需要使用plotly.js.我只能选择D3.js.

P.s.: Using plotly.js is not a requirement. I could go with D3.js only if that is an option.

推荐答案

您可以在Plotly箱形图对象的y-值中提供箱形图的值.请参见下面的代码段和讨论

You can provide the values for the box plot in the y-value of the Plotly box plot object. See the snippet below and the discussion here.

var min = 1;
var max = 11;
var med = 4.25;
var stdev = 2;

var y = [min,
         med - stdev,
         med - stdev,
         med,
         med + stdev,
         med + stdev,
         max
        ];

var box = {
  y: y,
  type: 'box'
};

Plotly.newPlot('myDiv', [box]);

<head>
  <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
        
<body>
  <div id="myDiv"></div>
</body>

这篇关于统计汇总数据中的绘图箱图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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