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']
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)
fig = plt.figure(figsize=(10, 10))
# standard plots
def ploting(dataset, j):
ax.plot(women_degrees['Year'],
women_degrees[dataset[j]],
c=cb_dark_blue,
label='Women',
linewidth=3)
ax.plot(women_degrees['Year'],
100-women_degrees[dataset[j]],
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(dataset[j])
ax.tick_params(bottom="off",
top="off",
left="off",
right="off",
labelbottom='off')
ax.set_yticks([0,100])
ax.axhline(50,c=(171/255, 171/255, 171/255), alpha=0.3)
if j == 0:
ax.text(2005, int(100-women_degrees[dataset[j]].tail(1)+10), 'Men')
ax.text(2002, int(women_degrees[dataset[j]].tail(1)-12), 'Women')
elif j == len(dataset)-1:
ax.text(2005, int(100-women_degrees[dataset[j]].tail(1)+10), 'Men')
ax.text(2001, int(women_degrees[dataset[j]].tail(1)-12), 'Women')
ax.tick_params(labelbottom='on')
for i in range(6):
# print stem_cats in the 1st column
ax = fig.add_subplot(6,3,3*i+1)
ploting(stem_cats,i)
if i<5:
# print lib_cats in the 2nd column, only 5 elements
ax = fig.add_subplot(6,3,3*i+2)
ploting(lib_arts_cats,i)
# print other_cats in the 1st column
ax = fig.add_subplot(6,3,3*i+3)
ploting(other_cats,i)
# improve layout without overlapping
fig.tight_layout()
plt.savefig('gender_degrees.png')