#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt

y0 = np.arange(0, 11) ** 3

mean = [69, 0]
cov = [[15, 8], [8, 15]]
np.random.seed(5)
x1, y1 = np.random.multivariate_normal(mean, cov, 2000).T
y1 += 180

x2 = np.arange(0, 28651, 5730)
r2 = np.log(0.5)
t2 = 5730
y2 = np.exp((r2 / t2) * x2)

x3 = np.arange(0, 21000, 1000)
r3 = np.log(0.5)
t31 = 5730
t32 = 1600
y31 = np.exp((r3 / t31) * x3)
y32 = np.exp((r3 / t32) * x3)

np.random.seed(5)
student_grades = np.random.normal(68, 15, 50)

fig = plt.figure()
fig.set_figheight(12)
fig.set_figwidth(12)
ax1 = plt.subplot2grid((3, 2), (0, 0), fig=fig)
ax2 = plt.subplot2grid((3, 2), (0, 1), fig=fig)
ax3 = plt.subplot2grid((3, 2), (1, 0), fig=fig)
ax4 = plt.subplot2grid((3, 2), (1, 1), fig=fig)
ax5 = plt.subplot2grid((3, 2), (2, 0), colspan=2, fig=fig)


# Define the figure with the number of subplots
# axs save an array of the number of plots
fig.suptitle('All in One', size=28)
font = {'size': 7.5}

plt.rc('font', **font)

# Normal plot
# red line
# Limit from 0 to 10
ax1.plot(y0, 'r')
ax1.set_xlim(0, 10)

# Scatter plot
# X and Y label defined
# Title defined
# Magenta color, '.' marking
ax2.scatter(x1, y1, c='m', marker='.')
ax2.set_title("Men's Height vs Weight")
ax2.set(xlabel='Height (in)', ylabel='Weight (lbs)')

# Linear plot
# Change scale
# X and Y label defined
# Title defined
# Y scale is logarithmical
# X limit from 0 to 28650
ax3.plot(x2, y2)
ax3.set_title('Exponential Decay of C-14')
ax3.set(xlabel='Time (years)', ylabel='Fraction Remaining')
ax3.set_yscale('log')
ax3.set_xlim(0, 28650)

# Plot with two lines
# Title defined
# First line with red and dashed line with label defined
# Second line with gren line and label defined
# X and Y label defined
# Limit of X and Y
ax4.set_title('Exponential Decay of Radioactive Elements')
ax4.plot(x3, y31, '--r', label='C-14')
ax4.plot(x3, y32, 'g', label='Ra-226')
ax4.set(xlabel='Time (years)', ylabel='Fraction Remaining')
ax4.set_xlim(0, 20000)
ax4.set_ylim(0, 1)

# Histogram
# bins defined
# Bars with black outlined
# Title defined
# X and Y label defined
# X limit and ticks
# Y limit
ax5.hist(student_grades, bins=10, edgecolor='black')
ax5.set_title('Project A')
ax5.set(xlabel='Grades', ylabel='Number of Students')
ax5.set_xlim(0)
ax5.set_xticks(np.arange(0, 101, 10))
ax5.set_ylim(0, 30)

plt.show()
