Connect A Mean Value To Histogram Pandas

[Solved] Connect A Mean Value To Histogram Pandas | Perl - Code Explorer | yomemimo.com
Question : connect a mean value to histogram pandas

Answered by : envious-elk-7eamc17pfi4w

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

Source : https://stackoverflow.com/questions/16180946/drawing-average-line-in-histogram-matplotlib | Last Update : Sat, 08 Aug 20

Answers related to connect a mean value to histogram pandas

Code Explorer Popular Question For Perl