0

I want to manipulate the labels of xticks from a plot created with pyplot. Im using a Jupyter Notebook.

import matplotlib.pyplot as plt
plt.plot(range(10))
ticks, labels = plt.xticks()
print(labels)

However, the output of this is the following, event though the labels in the plot are correct.

[Text(0, 0, ''), Text(0, 0, ''), Text(0, 0, ''), Text(0, 0, ''), Text(0, 0, ''), Text(0, 0, ''), Text(0, 0, '')]

It is difficult for me to recreate and adjust the labels and then set them, as I use a datetime index in my original data. Thus, I want to manipulate the already created labels. Do you have an idea, how i can get the correct labels or label strings in form of a list. (I know, that from the text object I can get the string using text.get_text())

Thanks for help.

akra1
  • 144
  • 1
  • 1
  • 12

0 Answers0