title: How to create a density plot in matplotlib?
body: <p>In R I can create the desired output by doing: </p>
  
  <pre><code>data = c(rep(1.5, 7), rep(2.5, 2), rep(3.5, 8),
           rep(4.5, 3), rep(5.5, 1), rep(6.5, 8))
  plot(density(data, bw=0.5))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/YFEin.png" alt="Density plot in R"></p>
  
  <p>In python (with matplotlib) the closest I got was with a simple histogram:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  data = [1.5]*7 + [2.5]*2 + [3.5]*8 + [4.5]*3 + [5.5]*1 + [6.5]*8
  plt.hist(data, bins=6)
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/LqadU.png" alt="Histogram in matplotlib"></p>
  
  <p>I also tried <a href="http://matplotlib.sourceforge.net/examples/api/histogram_demo.html" rel="noreferrer">the normed=True parameter</a> but couldn't get anything other than trying to fit a gaussian to the histogram.</p>
  
  <p>My latest attempts were around <code>scipy.stats</code> and <code>gaussian_kde</code>, following examples on the web, but I've been unsuccessful so far.</p>