1import numpy as np
2import matplotlib.pyplot as plt
3np.random.seed(6789)
4x = np.random.gamma(4, 0.5, 1000)
5result = plt.hist(x, bins=20, color='c', edgecolor='k', alpha=0.65)
6plt.axvline(x.mean(), color='k', linestyle='dashed', linewidth=1)
7
8min_ylim, max_ylim = plt.ylim()
9plt.text(x.mean()*1.1, max_ylim*0.9, 'Mean: {:.2f}'.format(x.mean()))