1 回答
TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超7個(gè)贊
嘗試這個(gè):
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as md
import matplotlib.dates as mdates
import datetime as dt
data = {"Date":['2019-2-25 14:24:04', '2019-2-25 14:29:02', '2019-2-20 17:02:14',
'2019-3-25 08:12:54', '2019-3-25 12:32:32'],
"Quiz":[1,2,2,3,4],
"Score":[10,3,7,4,9]}
df = pd.DataFrame.from_dict(data)
xs = df.Date.values
fig, ax = plt.subplots(1)
ax.set_xlabel("Date")
ax.set_ylabel("Score")
ax.plot_date(xs, df.Score)
fig.autofmt_xdate(rotation=45)
plt.show()
主要區(qū)別是刪除格式化業(yè)務(wù)并設(shè)置 xs = df.Date.values,然后讓圖表自己處理格式化fig.autofmt_xdate(rotation=45)。
添加回答
舉報(bào)
