Matplotlib中在X轴上显示日期和时间实战:date and time on the X-axis in Matplotlib
目录
Matplotlib中在X轴上显示日期和时间实战:date and time on the X-axis in Matplotlib
#不做日期和时间数据的处理直接可视化
from datetime import datetime as dt
from matplotlib import pyplot as plt, dates as mdates
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
dates = ["01/02/2020", "01/03/2020", "01/04/2020"]
x_values = [dt.strptime(d, "%m/%d/%Y").date() for d in dates]
y_values = [1, 2, 3]
ax = plt.gca()
# formatter = mdates.DateFormatter("%Y-%m-%d")
# ax.xaxis