4

I have an array of strings which contain dates formatted as such: '01/01/09'. I also have an array of floats with the date values.

I want to take these dates and ultimately display them as x tick labels on my graph.

How do I use the floats or strings to label the ticks on the x-axis on my matplotlib graph? (using something like xticks)

1 Answer 1

7

You set the count (and values) of the ticks using set_xticks. You set the text of the ticks using set_xticklabels

from matplotlib import pyplot as plt
plt.plot([1,2,3],[3,4,3])
ax = plt.gca()
ax.set_xticks([1,2,3])
ax.set_xticklabels(['1/1','1/2','1/3'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.