INNER CODE UNIT · Python
std_from_mean_kde
stefmolin/Hands-On-Data-Analysis-with-Pandas-2nd-edition · ch_06/viz.py:39
def std_from_mean_kde(data):
"""
Plot the KDE along with vertical reference lines
for each standard deviation from the mean.
Parameters:
- data: `pandas.Series` with numeric data
Returns:
Matplotlib `Axes` object.
"""
mean_mag, std_mean = data.mean(), data.std()
ax = data.plot(kind='kde')
ax.axvline(mean_mag, color='b', alpha=0.2, label='mean')
colors = ['green', 'orange', 'red']
multipliers = [1, 2, 3]