title: How to plot keys and values from dictionary in histogram
body: <p>I need to plot a histogram with the following dictionary</p>
  
  <pre><code>x = {5:289, 8:341, 1:1565, 4:655, 2:1337, 9:226, 7:399, 3:967, 6:405}
  </code></pre>
  
  <p>I need first keys be ordered from 1 to 9. Then the values will be plotted in the histogram, showing a maximum probability of 1.0. I have tried the following (plus other stuff).</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  plt.hist(x.keys(), x.values(), color='g', label = "Real distribution")
  plt.show()
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>plt.hist (x, bins = np.arange(9), color = 'g', label = "Real distribution")
  plt.show()
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>fsn_count_ = sorted(fsn_count)
  
  plt.hist (fsn_count_, bins = np.arange(9), color = 'b', label = "Real distribution")
  plt.plot ([0] + bf, color = 'g', label = "Benford Model")
  plt.xlabel ('Significant number')
  plt.ylabel ('Percentage')
  plt.xlim (1,9)
  plt.ylim (0,1)
  plt.legend (bbox_to_anchor = (1, 1), loc="upper right", borderaxespad=0.)
  plt.savefig (country_ + '.png')
  plt.show ()
  plt.clf ()
  
  distribution_sum = sum(bf)
  print('The sum of percentage distribution is:', distribution_sum)
  </code></pre>