I have a Pandas DataFrame containing 20 rows, indexed by datetime:
df.tail()
units value
time
2013-08-30T13:01:12 vehicles/h 662
2013-08-30T13:06:12 vehicles/h 701
2013-08-30T13:11:13 vehicles/h 477
2013-08-30T13:16:13 vehicles/h 179
2013-08-30T13:21:13 vehicles/h 576
I'm plotting it using matplotlib, like so:
ax = ls.plot(color='CC00CC')
# Only show hours and minutes
ax.set_xticklabels(
[dt.strftime("%H:%M:%S") for dt in ls.index.to_datetime()])
plt.setp(ax.get_yticklabels(), fontsize=8)
ax.set_ylabel("Counts")
ax.set_xlabel("5-minute intervals on %s" % (datetime.datetime.today().strftime("%d/%m/%Y")))
plt.title("Vehicles")
plt.tight_layout()
Which results in the following plot:

But only the first few times are being shown as x ticks. The right-most x tick should be labelled 12:21:13, and some more of the intermediate ticks should be shown. What have I done wrong?
set_xlabelde-couples your label text from you data. It is dangerous and should only be used only occasionally.