I am trying to rotate the x tick labels in a plot. I created a general function that plots in the style I want to plot. I do the following:
labels=ax2.get_xticklabels()
for i,label in labels:
labels[i]=label.get_text()
ax2.set_xticklabels(labels, rotation=30)
This produced plots with no x_tick labels, so I dug deeper: I had it print the label as it was looping through and they were empty text instances. However, this is where it gets weird: When I just get the labels (labels=ax2.get_xticklabels()), and have the plot function return the list of text instances (return labels), the Text instances in the list do have the correct string, and the code above produces a list of strings as intended. I am not sure why the text instances are empty when I try to edit it inside of the function, but correct when I have the function return labels unedited. Any advice?