title: How to draw a histogram with variable-width bins in Python?
body: <p>Suppose I have data <strong>[1,2,3, 7,8,9,9, 20,30,40,100,1000]</strong> for which I want to draw a histogram with Python. All the bins I care about is <strong>[0,5], [5,10], and [10, +∞)</strong>. How can I do it?</p>
  <p>The following wouldn't do it, of course.</p>
  <pre><code>import matplotlib.pyplot as plt
  
  data = [1,2,3, 7,8,9,9, 20,30,40,100,1000]
  plt.figure()
  plt.hist(data, bins=5, color=&quot;rebeccapurple&quot;)
  plt.show()
  </code></pre>