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']
fig = plt.figure(figsize=(30,15))
new_li = [stem_cats,lib_arts_cats,other_cats]
total = len(stem_cats) + len(lib_arts_cats) + len(other_cats)
for i in range(1,len(new_li)+1):
for j in range(len(new_li[i-1])):
ax = fig.add_subplot(6,3,i+(3*j))
ax.plot(women_degrees["Year"],women_degrees[new_li[i-1][j]],label = "Women",c = cb_dark_blue)
ax.plot(women_degrees["Year"],100 - women_degrees[new_li[i-1][j]],label = "Men",c = cb_orange)
for key,spine in ax.spines.items():
#removes spines
spine.set_visible(False)
ax.tick_params(bottom = "off",top="off", left="off", right="off", labelbottom = "off")#removes ticks
ax.set_yticks([0,100])
ax.set_xlim(1968, 2011)
ax.set_ylim(0,100)
ax.set_title(new_li[i-1][j])
ax.axhline(50,c=(171/255, 171/255, 171/255), alpha = 0.3)
#adding Male/Female text at topmost and bottommost plots
#max y-axis value at 2005
max_val = women_degrees.loc[women_degrees.shape[0]-1,new_li[i-1][0]]
plt.subplot(6,3,i).text(2005, max_val, 'Women')
plt.subplot(6,3,i).text(2005, 100 - max_val, 'Men')
if len(new_li[i-1]) == len(max(new_li)):
max_val = women_degrees.loc[women_degrees.shape[0]-1,new_li[i-1][5]]
ax.text(2005, max_val, 'Women')
ax.text(2005, 100 - max_val,'Men')
plt.savefig("gender_degrees.png")
plt.show()
print("done")