import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams

rcParams['font.family'] = 'serif'
rcParams['font.size'] = 16


ang = np.pi/6
mean = np.array([1, 3])
cov = np.array([[9, 0],
                [0, 1]])
rot = np.array([[np.cos(ang), -np.sin(ang)],
                [np.sin(ang), np.cos(ang)]])
cov = np.dot(rot, np.dot(cov, rot.T))

np.random.seed(seed=1)
data = np.random.multivariate_normal(mean, cov, size=(5000))
x = data[:, 0]
y = data[:, 1]

plt.figure(figsize=(8, 8))
plt.scatter(x, y, c="k", alpha=0.5, lw=0)
plt.arrow(1, 3, 3*np.cos(ang), 3*np.sin(ang), width=0.02, color="r", lw=2,
          overhang=0.1)
plt.arrow(1, 3, -np.sin(ang), np.cos(ang), width=0.02, color="r", lw=2,
          overhang=0.1)
plt.grid(True)
plt.axis("image")
plt.axis([-8, 10, -6, 12])
plt.savefig("GaussianScatterPCA.jpg")
plt.show()
