title: How do I plot a standard histogram data to a polar histogram using Python and pyplot?
body: <p>I have a list of angles in degrees. I want to display a polar histogram in which the [0°, 360°) range of values is subdivided into equal bins, and display how many values in the angles list fall into each bin. I get histogram data using the following code (and I've checked it is correct):</p>
  
  <pre><code>bins_number = 8 # the [0, 360) interval will be subdivided into this number of equal bins
  bins = np.linspace(0.0, 360.0, bins_number + 1)
  n, _, _ = plt.hist(angles, bins)
  </code></pre>
  
  <p>Now, I've tried to plot this data into a polar histogram using the following code:</p>
  
  <pre><code>plt.clf()
  width = 2 * np.pi / bins_number
  ax = plt.subplot(1, 1, 1, projection='polar')
  bars = ax.bar(bins[:bins_number], n, width=width, bottom=0.0)
  for bar in bars:
      bar.set_alpha(0.5)
  plt.show()
  </code></pre>
  
  <p>but what I get is shown in this image:
  <a href="https://i.stack.imgur.com/WdHV5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WdHV5.png" alt="enter image description here"></a></p>
  
  <p>As you can see, bars are not placed at the correct angle, and some of them overlap each other, while they should be all contiguous without overlapping.</p>
  
  <p>What am I doing wrong? Thank you in advance.</p>