I start with tree plots:
df = pd.DataFrame([1,20,3],[2,30,4],[3,40,5],columns=['mean','size','stat'])
fig,[ax1,ax2,ax3] = plt.subplots(1, 3, sharey=True)
ax1.barh(np.arange(len(df)),df['mean'].values, align='center')
ax2.barh(np.arange(len(df)),df['size'].values, align='center')
ax3.barh(np.arange(len(df)),df['stat'].values, align='center')
Is there a way to rotate the x axis labels on all three plots?
When you're done plotting, you can just loop over each xticklabel:
for ax in [ax1,ax2,ax3]:
for label in ax.get_xticklabels():
label.set_rotation(90)
You can do it for each ax your are creating:
ax1.xaxis.set_tick_params(rotation=90)
ax2.xaxis.set_tick_params(rotation=90)
ax3.xaxis.set_tick_params(rotation=90)
or you do it inside a for before showing the plot if you are building your axs using subplots:
for s_ax in ax:
s_ax.xaxis.set_tick_params(rotation=90)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With