使用Matplotlib绘制时间戳的步骤如下:
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
from datetime import datetime
timestamps = ['01.01.2022 12:00:00', '02.01.2022 13:30:00', '03.01.2022 14:45:00']
values = [10, 20, 15]
datetimes = [datetime.strptime(ts, '%d.%m.%Y %H:%M:%S') for ts in timestamps]
fig, ax = plt.subplots()
ax.xaxis.set_major_formatter(mdates.DateFormatter('%d.%m.%Y %H:%M:%S'))
ax.plot(datetimes, values)
ax.set_xlabel('Timestamp')
ax.set_ylabel('Value')
fig.autofmt_xdate()
plt.show()
关于matplotlib、时间戳和相关概念的详细解释,请参考以下内容:
以上就是使用Matplotlib将'%d.%m.%Y %H:%M:%S'格式的时间戳绘制图表的完整步骤和相关知识介绍。
领取专属 10元无门槛券
手把手带您无忧上云