Reputation: 21
I am trying to use matplotlib module to plot date vs. some values. I'd like to make some changes to the ticklables
of the x_axis
and to do that I am using the xaxis.get_ticklables()
. As the matplotlib Artist tutorial says this function gives a list of Text
instances. Now the question is, what is a Text
instance and is there any way I can convert a Text
instance to strings or numbers?
Thank you.
Upvotes: 2
Views: 1478
Reputation: 85432
You can get the text, i.e. the string, for all tick labels with:
label_texts = [label.get_text() for label in ax.xaxis.get_ticklabels()]
A tick label is rich matplotlib object with many ttributes:
>>> tick_label = ax.xaxis.get_ticklabels()[0]
>>> len(dir(tick_label))
213
Type:
>>> dir(tick_label)
to see their names.
Upvotes: 1