Q:

plot normal distribution given mean and sigma - python

I have some data in pandas dataframe
df['Difference'] = df.Congruent.values - df.Incongruent.values
mean = df.Difference.mean()
std = df.Difference.std(ddof=1)
median = df.Difference.median()
mode = df.Difference.mode()

and I want to plot a histogram together with normal distribution in 1 plot. Is there a plotting function that takes mean and sigma as arguments? I don't care whether  it is matplotplib, seaborn or ggplot. The best would be if I could mark also mode and median of the data all within 1 plot.

A:

You can use matplotlib/pylab with scipy.stats.norm.pdf and pass the mean and standard deviation as loc and scale:
import pylab
import numpy as np
from scipy.stats import norm
x = np.linspace(-10,10,1000)
y = norm.pdf(x, loc=2.5, scale=1.5)    # for example
pylab.plot(x,y)
pylab.show()

