I got a little problem and google couldn't really help me out. Here's my code:
from matplotlib import pyplot as plt
import numpy as np
job_r = list(ct_t.JobRole.unique())
att_y = ct_t[ct_t['Attrition']=='Yes']['Percentage'].values
att_n = ct_t[ct_t['Attrition']=='No']['Percentage'].values
# Sort by number of sales staff
idx = att_n.argsort()
job_r, att_y, att_n = [np.take(x, idx) for x in [job_r, att_y, att_n]]
y = np.arange(att_y.size)
fig, axes = plt.subplots(ncols=2, sharey=True, figsize=[8,8])
axes[0].barh(y, att_n, align='center', color='#43e653', zorder=10)
axes[0].set(title='NO')
axes[1].barh(y, att_y, align='center', color='#ed1c3c', zorder=10)
axes[1].set(title='YES')
axes[0].invert_xaxis()
axes[0].set(yticks=y, yticklabels=job_r)
axes[0].yaxis.tick_right()
for ax in axes.flat:
ax.margins(0.03)
ax.grid(True)
fig.tight_layout()
fig.subplots_adjust(wspace=0.7)
plt.show()
My current output:
Is there any way to center the shared y labels in the middle between those two subplots?
Can I increase the x-axis up to 1.0 ? Each time I do something like:
axes[1].set_xlabels(1.0)
my whole plot turns upside down.