在matplotlib中编辑X轴刻度标签的日期格式

问题描述:

我希望编辑x轴上日期的格式.下图显示了默认情况下它们在我的条形图中的显示方式.我想删除"Dec"和"2012"的重复,只沿x轴显示实际的日期数字.

I am looking to edit the formatting of the dates on the x-axis. The picture below shows how they appear on my bar graph by default. I would like to remove the repetition of 'Dec' and '2012' and just have the actual date numbers along the x-axis.

关于如何执行此操作的任何建议?

Any suggestions as to how I can do this?

简而言之:

import matplotlib.dates as mdates
myFmt = mdates.DateFormatter('%d')
ax.xaxis.set_major_formatter(myFmt)

matplotlib网站上的许多示例.我最常使用的一个是此处

Many examples on the matplotlib website. The one I most commonly use is here