I also stumbled across the error and found that making both your xtick_labels and xticks a list of equal length works. So in your case something like :
def month(num):
# returns month name based on month number
num_elements = len(x)
X_Tick_List = []
X_Tick_Label_List=[]
for item in range (0,num_elements):
X_Tick_List.append(x[item])
X_Tick_Label_List.append(month(item+1))
plt.xticks(ticks=X_Tick_List,labels=X_Tick_LabeL_List, rotation=25,fontsize=8)