Reputation: 703
As the title describes, I am using the subplots method to make bar charts. Everything works well but I can't figure out how to rotate the x tick labels. My graphing code is:
f, axarr = plt.subplots(2, sharex=True)
axarr[0].set_xticklabels(file2_temp)
axarr[0].xaxis.set_ticks(y)
axarr[0].bar(np.arange(len(file_temp)), stddev_temp, align='center', alpha=0.4)
axarr[1].bar(np.arange(len(file_RH)), stddev_RH, align='center', alpha=0.4)
axarr[1].tick_params(axis='x', pad=30)
plt.show()
Where file2_temp and RH are lists and stddev_temp and RH are my data.
Any help would be great. Thanks!
Upvotes: 1
Views: 6445
Reputation: 13610
You can rotate ticks using setp.
Here's an example modified from your your post:
import matplotlib.pyplot as plt
from numpy.random import rand
import numpy as np
f, axarr = plt.subplots(2, sharex=True)
axarr[0].bar(np.arange(1,11), rand(10), align='center', alpha=0.4)
axarr[1].bar(np.arange(1,11), rand(10), align='center', alpha=0.4)
axarr[1].tick_params(axis='x', pad=30)
plt.setp(plt.xticks()[1], rotation=45)
plt.show()
Upvotes: 8