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