%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
women_degrees = pd.read_csv('percent-bachelors-degrees-women-usa.csv')
cb_dark_blue = (0/255,107/255,164/255)
cb_orange = (255/255, 128/255, 14/255)
stem_cats = ['Engineering', 'Computer Science', 'Psychology', 'Biology', 'Physical Sciences', 'Math and Statistics']
fig = plt.figure(figsize=(18, 3))
for sp in range(0,6):
ax = fig.add_subplot(1,6,sp+1)
ax.plot(women_degrees['Year'], women_degrees[stem_cats[sp]], c=cb_dark_blue, label='Women', linewidth=3)
ax.plot(women_degrees['Year'], 100-women_degrees[stem_cats[sp]], c=cb_orange, label='Men', linewidth=3)
ax.spines["right"].set_visible(False)
ax.spines["left"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.spines["bottom"].set_visible(False)
ax.set_xlim(1968, 2011)
ax.set_ylim(0,100)
ax.set_title(stem_cats[sp])
ax.tick_params(bottom="off", top="off", left="off", right="off")
if sp == 0:
ax.text(2005, 87, 'Men')
ax.text(2002, 8, 'Women')
elif sp == 5:
ax.text(2005, 62, 'Men')
ax.text(2001, 35, 'Women')
plt.show()
stem_cats = ['Psychology', 'Biology', 'Math and Statistics', 'Physical Sciences', 'Computer Science', 'Engineering']
lib_arts_cats = ['Foreign Languages', 'English', 'Communications and Journalism', 'Art and Performance', 'Social Sciences and History']
other_cats = ['Health Professions', 'Public Administration', 'Education', 'Agriculture','Business', 'Architecture']
cats = [stem_cats, lib_arts_cats, other_cats] # 3 x 6 ragged array
fig = plt.figure(figsize=(18,20)) # must be on the same cell as the plots
n_cols = len(cats) # = 3
max_row = max([len(cats[:][i]) for i in range(n_cols)]) # = 6, the length of the largest column
for i in range(n_cols): # plots are done columnwise
n_rows = len(cats[i]) # ragged columns so it's 6 or 5
for j in range(n_rows):
cat = cats[i][j]
ax = fig.add_subplot(max_row, n_cols, (n_cols*j+i)+1)
ax.set_title(cat)
ax.plot(women_degrees['Year'], women_degrees[cat], c=cb_dark_blue, label='Women', linewidth=3)
ax.plot(women_degrees['Year'], 100-women_degrees[cat], c=cb_orange, label='Men', linewidth=3)
for key,spine in ax.spines.items():
spine.set_visible(False)
ax.set_xlim(1968, 2011)
ax.set_ylim(0,100)
ax.set_yticks([0, 100])
ax.axhline(50, c=(171/255,)*3, alpha=0.3)
ax.tick_params(bottom=False, top=False, left=False, right=False, labelbottom=False)
if i == 0 and j == 0:
ax.text(2003, 85, 'Women')
ax.text(2005, 10, 'Men')
elif i == 0 and j == n_rows - 1:
ax.text(2005, 87, 'Men')
ax.text(2003, 7, 'Women')
ax.tick_params(labelbottom=True)
elif i == 1 and j == 0:
ax.text(2003, 78, 'Women')
ax.text(2005, 18, 'Men')
elif i == 1 and j == n_rows - 1:
ax.tick_params(labelbottom=True)
elif i == 2 and j == 0:
ax.text(2003, 90, 'Women')
ax.text(2005, 5, 'Men')
elif i == 2 and j == n_rows - 1:
ax.text(2005, 62, 'Men')
ax.text(2003, 30, 'Women')
ax.tick_params(labelbottom=True)
plt.savefig('gender_degrees.png')
plt.show()