I am building a line plot with two lines, one for high temperatures and the other for low temperatures. The x-axis is based on days over one complete year in datetime format (2014-01-01, etc.). However, I changed the labels–not the data–for months (Jan, Feb, Mar, etc). The problem is that the first label 'Jan' is in the origin. What I want is to move all labels to the right to center them between ticks.
fig, ax = plt.subplots()
plt.plot(x, y1)
plt.plot(x, y2)
# Change x-axis from %y-%m-%d format to %m:
monthsFmt = mdates.DateFormatter('%m')
plt.gca().xaxis.set_major_formatter(monthsFmt)
# Replace numeric x-axis labels (1,2,3, ..., 12) for abbreviations of months ('Jan', 'Feb', 'Mar', etc.):
labels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
ax.set_xticklabels(labels)
# CODE GOES HERE TO CENTER X-AXIS LABELS...
# Render plot:
plt.show()
This is the result that I am looking for: