-
这个
'record_date'
值是字符串,而不是日期时间。
-
df.record_date = pd.to_datetime(df.record_date)
-
通常,折线图应用于连续时间序列数据。
折线图
ax = df.plot(x='record_date', y='transaction_today_amt', figsize=(12, 7))
散点图
ax = df.plot(kind='scatter', x='record_date', y='transaction_today_amt', marker='.', figsize=(12, 7))
条形图
-
使用
matplotlib
直接,因为xticks是日期时间序数,它将用Year标记x轴。
-
ax.get_xticks()
array([12418., 13149., 13879., 14610., 15340., 16071., 16801., 17532., 18262., 18993., 19723.])
fig, ax = plt.subplots(figsize=(8, 5), dpi=200)
ax.bar(x='record_date', height='transaction_today_amt', data=df)
ax.set_yscale('log')
-
pandas
将xticks视为离散的,并绘制所有xticks。
ax = df.plot(kind='bar', x='record_date', y='transaction_today_amt', figsize=(12, 7))