Since I'm not sure if the potential duplicate actually answers the question here, this is a way to produce a stacked histogram using numpy.histogram and matplotlib bar plot. 
import pandas as pd
import numpy as np;np.random.seed(1)
import matplotlib.pyplot as plt
df = pd.DataFrame({"x" : np.random.exponential(size=100),
                   "class" : np.random.choice([1,2,5],100)})
_, edges = np.histogram(df["x"], bins=10)
histdata = []; labels=[]
for n, group in df.groupby("class"):
    histdata.append(np.histogram(group["x"], bins=edges)[0])
    labels.append(n)
hist = np.array(histdata) 
histcum = np.cumsum(hist,axis=0)
plt.bar(edges[:-1],hist[0,:], width=np.diff(edges)[0],
            label=labels[0], align="edge")
for i in range(1,len(hist)):
    plt.bar(edges[:-1],hist[i,:], width=np.diff(edges)[0],
            bottom=histcum[i-1,:],label=labels[i], align="edge")
plt.legend(title="class")
plt.show()
