I have also tried this:
new_pt = new_df.pivot_table(index=“age_cleaned”,values=“dissatisfied”)
exper_pt = exper_df.pivot_table(index=“age_cleaned”,values=“dissatisfied”)
estab_pt = estab_df.pivot_table(index=“age_cleaned”,values=“dissatisfied”)
vet_pt = vet_df.pivot_table(index=“age_cleaned”,values=“dissatisfied”)
df1 = new_pt.reset_index()
df2 = exper_pt.reset_index()
df3 = estab_pt.reset_index()
df4 = vet_pt.reset_index()
fig, ax = plt.subplots(2,2,figsize=(15,15))
for r in df1.itertuples():
ax[0,0].bar(r[0],r[2],label=r[1])
plt.xticks(df1.index,df1.age_cleaned)
for r in df2.itertuples():
ax[0,1].bar(r[0],r[2],label=r[1])
plt.xticks(df2.index,df2.age_cleaned)
for r in df3.itertuples():
ax[1,0].bar(r[0],r[2],label=r[1])
plt.xticks(df3.index,df3.age_cleaned)
for r in df4.itertuples():
ax[1,1].bar(r[0],r[2],label=r[1])
plt.xticks(df4.index,df4.age_cleaned)
AND
new_pt.plot(kind = ‘bar’, color=“green”)
plt.xlabel(“Employee Age”)
plt.ylabel(“Percent Dissatisfied”)
plt.ylim(0,1)
L=plt.legend()
L.get_texts()[0].set_text(‘New’)
plt.show()
exper_pt.plot(kind = ‘bar’)
plt.xlabel(“Employee Age”)
plt.ylabel(“Percent Dissatisfied”)
plt.ylim(0,1)
L=plt.legend()
L.get_texts()[0].set_text(‘Experienced’)
plt.show()
estab_pt.plot(kind = ‘bar’, color=“red”)
plt.xlabel(“Employee Age”)
plt.ylabel(“Percent Dissatisfied”)
plt.ylim(0,1)
L=plt.legend()
L.get_texts()[0].set_text(‘Established’)
plt.show()
estab_pt.plot(kind = ‘bar’, color=“purple”)
plt.xlabel(“Employee Age”)
plt.ylabel(“Percent Dissatisfied”)
plt.ylim(0,1)
L=plt.legend()
L.get_texts()[0].set_text(‘Veteran’)
plt.show()
Which gives me four separate graphs. What I want is four subplots with easy to read labeling and consistent y axis. Thank you for the help!