File talk:Cohens d 4panel.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
import numpy as np
import matplotlib.pyplot as plt

def f(mu):
    X = np.linspace(-5, 5, 200)
    Y = np.exp(-(X-mu)**2/2)/np.sqrt(2*np.pi)
    return X,Y

def g(mu1, mu2):
    X1,Y1 = f(mu1)
    X2,Y2 = f(mu2)
    return X1,Y1,X2,Y2

plt.clf()
plt.figure(figsize=(2.5,2.5))

ax = plt.axes([0.03,0.53,0.45,0.45])
ax.set_yticks([])
ax.set_xticks([])
X1,Y1,X2,Y2 = g(0, 0.5)
plt.text(0.03, 0.87, "d=0.5", transform=ax.axes.transAxes, size=10)
plt.plot(X1, Y1, '-', color='orange', lw=3, alpha=0.7)
plt.plot(X2, Y2, '-', color='purple', lw=3, alpha=0.7)
plt.ylim(0,0.41)

ax = plt.axes([0.53,0.53,0.45,0.45])
plt.text(0.03, 0.87, "d=1", transform=ax.axes.transAxes, size=10)
ax.set_yticks([])
ax.set_xticks([])
X1,Y1,X2,Y2 = g(0, 1)
plt.plot(X1, Y1, '-', color='orange', lw=3, alpha=0.7)
plt.plot(X2, Y2, '-', color='purple', lw=3, alpha=0.7)
plt.ylim(0,0.41)

ax = plt.axes([0.03,0.03,0.45,0.45])
plt.text(0.03, 0.87, "d=2", transform=ax.axes.transAxes, size=10)
ax.set_yticks([])
ax.set_xticks([])
X1,Y1,X2,Y2 = g(-1, 1)
plt.plot(X1, Y1, '-', color='orange', lw=3, alpha=0.7)
plt.plot(X2, Y2, '-', color='purple', lw=3, alpha=0.7)
plt.ylim(0,0.41)

ax = plt.axes([0.53,0.03,0.45,0.45])
ax.set_yticks([])
ax.set_xticks([])
plt.text(0.03, 0.87, "d=3", transform=ax.axes.transAxes, size=10)
X1,Y1,X2,Y2 = g(-1, 2)
plt.plot(X1, Y1, '-', color='orange', lw=3, alpha=0.7)
plt.plot(X2, Y2, '-', color='purple', lw=3, alpha=0.7)
plt.xlim(-6,6)
plt.ylim(0,0.41)

plt.savefig("cohens_d_4panel.svg")