-1

I am working on looking at how age and time at a company influences resignation due to dissatisfaction.

I have a dataframe ("combined_updated") that has these columns:

"age_updated", "service_cat", and "dissatisfied."

"age_updated" and "service_cat" are strings. "age_updated" includes age ranges, and "service_cat" is a string which described the career stage of the employee (i.e. "New", "Experienced", etc.).

"dissatisfied" is boolean with True working as 1 and False as 0 in a pivot table. The pivot table therefore shows the % dissatisfied in certain groups.

I would like to make four bar graphs within a subplot with one graph looking at each career stage, with the y axis as % dissatisfied and the x axis as age.

So far I have written code that puts it all on one graph:

dis_pt = combined_updated.pivot_table(index=“service_cat”,columns=“age_cleaned”,values=“dissatisfied”)
dis_pt.plot(kind=“bar”)

Pivot Table

Graph so far

Does anyone know how to break this apart into subplots with appropriate labeling? Thanks!

T N
  • 1
  • 2
  • Please include a sample of data. See [How to make good reproducible pandas examples](https://stackoverflow.com/q/20109391/1422451)? – Parfait Dec 12 '19 at 17:44
  • I added in the pivot table to give some more information. Thank you for your feedback as this is my first post. – T N Dec 13 '19 at 18:56

1 Answers1

0

You can set the axes for each plot individually.


ax = plt.subplot("410")
dis_plt.iloc[0,:].plot(kind="bar", ax= ax)

ax = plt.subplot("411")
dis_plt.iloc[1,:].plot(kind="bar", ax= ax)

ax = plt.subplot("412")
dis_plt.iloc[2,:].plot(kind="bar", ax= ax)

ax = plt.subplot("413")
dis_plt.iloc[3,:].plot(kind="bar", ax= ax)

plt.show()

abhilb
  • 5,639
  • 2
  • 20
  • 26