Plot line graph from histogram data in matplotlib

You can save the output of hist and then plot it.

import numpy as np
import pylab as p

data=np.array(np.random.rand(1000))
y,binEdges=np.histogram(data,bins=100)
bincenters = 0.5*(binEdges[1:]+binEdges[:-1])
p.plot(bincenters,y,'-')
p.show()

I am very late to the party - but maybe this will be useful to someone else. I think what you need to do is set the histtype parameter to 'step', i.e.

ax.hist(data,bins=100,range=(minimum,maximum),facecolor="r", histtype = 'step')

See also http://matplotlib.sourceforge.net/examples/pylab_examples/histogram_demo_extended.html


Seaborn had what I needed:

import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt

sb.distplot(data, hist=False)
plt.show()