matplotlib hist gives me "too many values to unpack"
<p>I want to create a frequency plot of a sample whose values lie between -1 and 1.</p>

<p>creating the histogram using numpy works just fine:</p>

<pre><code>freq, bins = np.histogram(sample, bins=np.arange(-1,1,0.05) )
</code></pre>

<p>but creating a plot using the same bins gives me an error (see title):</p>

<pre><code>plt.hist(freq, range=bins)
</code></pre>

<p>In addition to this, how is it possible to adjust the x-labels such that the correct bin-values are shown?</p>

<p><strong>minimal working example:</strong></p>

<pre><code>import matplotlib.pyplot as plt
import numpy as np


if __name__ == "__main__":

  sample =  np.random.uniform(-1,1,100)
  freq, bins = np.histogram(sample, bins=np.arange(-1,1,0.05) )

  plt.figure()
  plt.hist(freq, range=bins)
  plt.show()
</code></pre>