Data¶
This dataset contains the details of the percentage of women who has bachelors degree in the year from 1970 to 2012
In [2]:
women_degrees = pd.read_csv("percent-bachelors-degrees-women-usa.csv")
In [3]:
print(women_degrees.head())
In [4]:
women_degrees.shape
Out[4]:
Plotting : Biology degree awareded to women¶
In [5]:
plt.plot(women_degrees["Year"],women_degrees["Biology"])
Out[5]:
Plotting : Men vs Women in Biology degree¶
In [6]:
plt.plot(women_degrees["Year"], 100 - women_degrees["Biology"], c='red', label ='Men')
plt.plot(women_degrees["Year"], women_degrees["Biology"], c='blue', label ='Women')
plt.legend(loc = "upper right")
plt.title('Percentage of Biology Degrees Awarded By Gender')
Out[6]:
Multiple plots¶
In [7]:
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,3)
ax4 = fig.add_subplot(2,2,4)
major_cats = ['Biology', 'Computer Science', 'Engineering', 'Math and Statistics']
ax = [ax1,ax2,ax3,ax4]
for i in range(len(major_cats)):
ax[i].plot(women_degrees["Year"],women_degrees[major_cats[i]], c ="red", label = "women" )
ax[i].plot(women_degrees["Year"],100-women_degrees[major_cats[i]], c ="blue", label = "men" )
ax[i].set_title(major_cats[i])
ax[i].set_ylim(0,100)
plt.legend()
Out[7]:
Selecting an appropriate color for color blinded people:¶
In [8]:
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,3)
ax4 = fig.add_subplot(2,2,4)
major_cats = ['Biology', 'Computer Science', 'Engineering', 'Math and Statistics']
ax = [ax1,ax2,ax3,ax4]
cb_dark_blue = (0/255,107/255,164/255)
cb_orange = (255/255, 128/255,14/255)
for i in range(len(major_cats)):
ax[i].plot(women_degrees["Year"],women_degrees[major_cats[i]], c =cb_dark_blue, label = "women" )
ax[i].plot(women_degrees["Year"],100-women_degrees[major_cats[i]], c =cb_orange, label = "men" )
ax[i].set_title(major_cats[i])
ax[i].set_ylim(0,100)
plt.legend()
Out[8]:
Adding Line width¶
In [9]:
fig = plt.figure(figsize=(12,8))
ax1 = fig.add_subplot(2,2,1)
ax2 = fig.add_subplot(2,2,2)
ax3 = fig.add_subplot(2,2,3)
ax4 = fig.add_subplot(2,2,4)
major_cats = ['Biology', 'Computer Science', 'Engineering', 'Math and Statistics']
ax = [ax1,ax2,ax3,ax4]
cb_dark_blue = (0/255,107/255,164/255)
cb_orange = (255/255, 128/255,14/255)
for i in range(len(major_cats)):
ax[i].plot(women_degrees["Year"],women_degrees[major_cats[i]], c =cb_dark_blue, label = "women", linewidth = 3 )
ax[i].plot(women_degrees["Year"],100-women_degrees[major_cats[i]], c =cb_orange, label = "men", linewidth = 3 )
ax[i].set_title(major_cats[i])
ax[i].set_ylim(0,100)
plt.legend()
Out[9]:
In [10]:
fig = plt.figure(figsize=(18,3))
ax1 = fig.add_subplot(1,6,1)
ax2 = fig.add_subplot(1,6,2)
ax3 = fig.add_subplot(1,6,3)
ax4 = fig.add_subplot(1,6,4)
ax5 = fig.add_subplot(1,6,5)
ax6 = fig.add_subplot(1,6,6)
major_cats = ['Engineering', 'Computer Science', 'Psychology', 'Biology', 'Physical Sciences', 'Math and Statistics']
ax = [ax1,ax2,ax3,ax4, ax5,ax6]
cb_dark_blue = (0/255,107/255,164/255)
cb_orange = (255/255, 128/255,14/255)
for i in range(len(major_cats)):
ax[i].plot(women_degrees["Year"],women_degrees[major_cats[i]], c =cb_dark_blue, label = "women", linewidth = 3 )
ax[i].plot(women_degrees["Year"],100-women_degrees[major_cats[i]], c =cb_orange, label = "men", linewidth = 3 )
ax[i].set_title(major_cats[i])
ax[i].set_xlim(1968, 2011)
ax[i].set_ylim(0,100)
plt.legend()
Out[10]:
Replacing the legend with annotations¶
In [11]:
fig = plt.figure(figsize=(18,3))
ax1 = fig.add_subplot(1,6,1)
ax2 = fig.add_subplot(1,6,2)
ax3 = fig.add_subplot(1,6,3)
ax4 = fig.add_subplot(1,6,4)
ax5 = fig.add_subplot(1,6,5)
ax6 = fig.add_subplot(1,6,6)
major_cats = ['Engineering', 'Computer Science', 'Psychology', 'Biology', 'Physical Sciences', 'Math and Statistics']
ax = [ax1,ax2,ax3,ax4, ax5,ax6]
cb_dark_blue = (0/255,107/255,164/255)
cb_orange = (255/255, 128/255,14/255)
for i in range(len(major_cats)):
ax[i].plot(women_degrees["Year"],women_degrees[major_cats[i]], c =cb_dark_blue, label = "women", linewidth = 3 )
ax[i].plot(women_degrees["Year"],100-women_degrees[major_cats[i]], c =cb_orange, label = "men", linewidth = 3 )
ax[i].set_title(major_cats[i])
ax[i].set_xlim(1968, 2011)
ax[i].set_ylim(0,100)
if i ==0:
ax[i].text(2003,87,'Men')
ax[i].text(2000,8,'Women')
if i == 5:
ax[i].text(2003,62,'Men')
ax[i].text(2000,35,'Women')
No comments :
Post a Comment