且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[matplotlib]:在 x 轴上写日期

更新时间:2023-11-23 23:49:04

ax.fmt_xdata 是日期格式,通常仅用于交互式绘图中的悬停功能.

ax.fmt_xdata is the formatter for the dates usually only used for the hover functionality in interactive plots.

您要在此处将xaxis的主要格式化程序设置为 DateFormatter :

What you want here is to set the major formatter of the xaxis to a DateFormatter:

ax.xaxis.set_major_formatter(DateFormatter('%b-%d-%Y'))