如何更改 matplotlib X 轴时间戳格式
有时你会在 Matplotlib 中得到奇怪的时间戳格式选择,如 22 19:40(表示某月 22 日 19:40)。

这很容易修复:
matplotlib_timestamp_format.py
import matplotlib.dates as mdates
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))这将生成此图像,例如:

Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow