Given the remarks in the comments, I guess something like the following is what you're looking for:
import numpy as np
import matplotlib.pyplot as plt
def plot_exponential_density(mu, xmax, fmt, label):
x = np.arange(0, xmax, 0.1)
y = 1/mu * np.exp(-x/mu)
plt.plot(x, y, fmt, label=label)
def sample_and_plot(N, color):
# first sample N valus
samples = np.zeros( (N,1) )
for i in range(0,N):
samples[i] = np.random.exponential()
# determine the mean
mu = np.mean(samples)
print("N = %d ==> mu = %f" % (N, mu))
# plot a histogram of the samples
(n, bins) = np.histogram(samples, bins=int(np.sqrt(N)), density=True)
plt.step(bins[:-1], n, color=color, label="samples N = %d" % N)
xmax = max(bins)
# plot the density according to the estimated mean
plot_exponential_density(mu, xmax, color + "--", label="estimated density N = %d" % N)
return xmax
# sample 100 values, draw a histogram, and the density according to
# the estimated mean
xmax1 = sample_and_plot(100, 'r')
# do the same for 1000 samples
xmax2 = sample_and_plot(10000, 'b')
# finally plot the true density
plot_exponential_density(1, max(xmax1, xmax2), 'k', "true density")
# add a legend
plt.legend()
# and show the plot
plt.show()

I used 100 and 10,000 samples, since with 1,000 samples the estimate is already pretty good. But still with just 100 samples I'm somewhat surprised how good the estimate of the mean and thus of the density is. Given just the histogram without the knowledge that the samples are drawn from an exponential distribution, I'm not sure I would recognize an exponential distribution here ...