Ploting box plot from statistical summary data

巧了我就是萌 提交于 2019-12-25 00:29:39

问题


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

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.: Using plotly.js is not a requirement. I could go with D3.js only if that is an option.


回答1:


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>


来源:https://stackoverflow.com/questions/53944430/ploting-box-plot-from-statistical-summary-data

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