【发布时间】:2021-06-17 00:18:36
【问题描述】:
我有以下熊猫数据框:
使用 Matplotlib 绘制折线图时,x 轴(日期)都被挤压在一起。如下图:
您知道如何做到这一点吗?我对此比较陌生,我使用的代码如下:
import matplotlib.pyplot as plt
plt.plot(df_temp['Mes'], df_temp['data science'], label='data science')
plt.plot(df_temp['Mes'], df_temp['machine learning'], label='machine learning')
plt.plot(df_temp['Mes'], df_temp['deep learning'], label='deep learning')
plt.xlabel('Date')
plt.ylabel('Popularity')
plt.title('Popularity of AI terms by date')
plt.grid(True)
plt.legend()
非常感谢
【问题讨论】:
-
将我转换为日期时间。它被绘制为字符串
标签: python pandas matplotlib data-visualization