I have a panda data frame and I am trying to plot two columns vs each other. But the problem is that my xtick labels are being shown to the full precision. How can abbreviate that (My Xaxis values are tuple)?
fig = plt.figure(figsize=(13,160))
plt.style.use('ggplot')
sns.set_style('ticks')
plt.rcParams['font.size'] = 12
n = 0
for name, group in a.groupby(['Config','prot_state','repeat','leg']):
ax = fig.add_subplot(20,2,n+1)
group = group.sort_values(by='Lambda')
title = name[0]+'-'+name[1]+'-'+name[2]+'('+name[3]+')'
ax = group.plot(y='A', x='Lambda', ax=ax, marker='o', lw=3, label='Chain_A', title=title)
ax = group.plot(y='B', x='Lambda', ax=ax, marker='o', lw=3, label='Chain_B', title=title)
ax.set_xlabel('$\lambda_{Coul}$, $\lambda_{Vdw}$')
ax.set_ylabel('$\Delta G$ (KJ/mol)')
ax.get_xaxis().get_major_formatter()
sns.despine(offset=10, ax=ax)
labels = ax.get_xticklabels()
plt.setp(labels, rotation=90, fontsize=10)
ax.xaxis.set_major_formatter(FormatStrFormatter('%.1f'))
plt.xticks(range(len(group['Lambda'])), group['Lambda'])
n = n+1
fig = ax.get_figure()
plt.tight_layout()
fig.savefig('{}.pdf'.format('dg-dlambda'))
Does anyone know how can I abbreviate this to two digits?