Q:

Python & Matplotlib - Creating date ticks from string

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)

A:

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'])

