How to draw a histogram with frequency using Plotly.js?
Plotly.js provides API to draw histogram with set of values but not with frequency values.
You can find more about Plotly Histograms here - https://plot.ly/javascript/histograms/
Here is an example:
If the sample set is { 2, 3, 4, 5, 2, 2, 2, 3, 5 }. Plotly plots it this way - https://codepen.io/sgsvenkatesh/pen/eEyyMJ
var x = [2, 3, 4, 5, 2, 2, 2, 3, 5];
var trace = {
x: x,
type: 'histogram',
};
var data = [trace];
Plotly.newPlot('myDiv', data);
But this is the data I have
x = [2, 3, 4, 5];
y = [4, 2, 1, 1];
This represents that values 0-2 are repeated 4 times, 2-3 is repeated 2 times and so on.
How can I plot this using Plotly.js?