%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']
# Total list
total_cats=[stem_cats, lib_arts_cats,other_cats]
fig = plt.figure(figsize=(10,20))
for i in range(len(total_cats)):
for sp in range(len(total_cats[i])):
ax = fig.add_subplot(6,3,(sp*3)+(i+1))
ax.plot(women_degrees['Year'], women_degrees[total_cats[i][sp]], c=cb_dark_blue, label='Women', linewidth=3)
ax.plot(women_degrees['Year'], 100-women_degrees[total_cats[i][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(total_cats[i][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()
total_cats=[stem_cats, lib_arts_cats,other_cats]
fig = plt.figure(figsize=(10,20))
for i in range(len(total_cats)):
for sp in range(len(total_cats[i])):
ax = fig.add_subplot(6,3,(sp*3)+(i+1))
ax.plot(women_degrees['Year'], women_degrees[total_cats[i][sp]], c=cb_dark_blue, label='Women', linewidth=3)
ax.plot(women_degrees['Year'], 100-women_degrees[total_cats[i][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(total_cats[i][sp])
#Code starts here
ax.tick_params(bottom="off", top="off", left="off", right="off",labelbottom='off')
#Code ends here
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()
total_cats=[stem_cats, lib_arts_cats,other_cats]
fig = plt.figure(figsize=(10,20))
for i in range(len(total_cats)):
for sp in range(len(total_cats[i])):
ax = fig.add_subplot(6,3,(sp*3)+(i+1))
ax.plot(women_degrees['Year'], women_degrees[total_cats[i][sp]], c=cb_dark_blue, label='Women', linewidth=3)
ax.plot(women_degrees['Year'], 100-women_degrees[total_cats[i][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(total_cats[i][sp])
ax.tick_params(bottom="off", top="off", left="off", right="off",labelbottom='off')
#Code starts here
ax.set_yticks([0,100])
#Code ends here
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()
total_cats=[stem_cats, lib_arts_cats,other_cats]
fig = plt.figure(figsize=(10,20))
for i in range(len(total_cats)):
for sp in range(len(total_cats[i])):
ax = fig.add_subplot(6,3,(sp*3)+(i+1))
ax.plot(women_degrees['Year'], women_degrees[total_cats[i][sp]], c=cb_dark_blue, label='Women', linewidth=3)
ax.plot(women_degrees['Year'], 100-women_degrees[total_cats[i][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(total_cats[i][sp])
ax.tick_params(bottom="off", top="off", left="off", right="off",labelbottom='off')
ax.set_yticks([0,100])
#Code starts here
ax.axhline(50, c=(171/255, 171/255, 171/255), alpha=0.3)
#Code endss here
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.savefig('Field_Gender_ratio.png')
plt.show()
fig = plt.figure(figsize=(15,25))
for sp in range(len(stem_cats)):
ax = fig.add_subplot(6,3,(sp*3)+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')
for sp2 in range(len(lib_arts_cats)):
ax2 = fig.add_subplot(6,3,(sp2*3)+2)
ax2.plot(women_degrees['Year'], women_degrees[lib_arts_cats[sp2]], c=cb_dark_blue, label='Women', linewidth=3)
ax2.plot(women_degrees['Year'], 100-women_degrees[lib_arts_cats[sp2]], c=cb_orange, label='Men', linewidth=3)
ax2.spines["right"].set_visible(False)
ax2.spines["left"].set_visible(False)
ax2.spines["top"].set_visible(False)
ax2.spines["bottom"].set_visible(False)
ax2.set_xlim(1968, 2011)
ax2.set_ylim(0,100)
ax2.set_title(lib_arts_cats[sp2])
ax2.tick_params(bottom="off", top="off", left="off", right="off")
if sp2 == 0:
ax2.text(2005, 87, 'Men')
ax2.text(2002, 8, 'Women')
elif sp2 == 5:
ax2.text(2005, 62, 'Men')
ax2.text(2001, 35, 'Women')
for sp in range(len(other_cats)):
ax3 = fig.add_subplot(6,3,(sp*3)+3)
ax3.plot(women_degrees['Year'], women_degrees[other_cats[sp]], c=cb_dark_blue, label='Women', linewidth=3)
ax3.plot(women_degrees['Year'], 100-women_degrees[other_cats[sp]], c=cb_orange, label='Men', linewidth=3)
ax3.spines["right"].set_visible(False)
ax3.spines["left"].set_visible(False)
ax3.spines["top"].set_visible(False)
ax3.spines["bottom"].set_visible(False)
ax3.set_xlim(1968, 2011)
ax3.set_ylim(0,100)
ax3.set_title(other_cats[sp])
ax3.tick_params(bottom="off", top="off", left="off", right="off")
if sp == 0:
ax3.text(2005, 87, 'Men')
ax3.text(2002, 8, 'Women')
elif sp == 5:
ax3.text(2005, 62, 'Men')
ax3.text(2001, 35, 'Women')
plt.show()