def plot_post(prior, like, post, x): maxy = max(max(prior), max(like), max(post)) plt.figure(figsize=(12, 4)) plt.plot(x, like, label='likelihood', linewidth=12, color='black', alpha=.2) plt.plot(x, prior, label='prior') plt.plot(x, post, label='posterior', color='green') plt.ylim(0, maxy) plt.xlim(0, 1) plt.title('Density of prior, likelihood and posterior') plt.xlabel('Parameter value') plt.ylabel('Density') plt.legend() post = posterior(pp, l) plot_post(pp, l, post, p)