使用matplotlib绘制熊猫数据框时管理xticks

时间:2018-09-06 10:16:02

标签: pandas datetime matplotlib

我有一个带有一列dtype datetime64的数据框。它包含的日期为2017年1月1日(2017年1月)-2018年4月1日(2018年4月)。我使用matplotlib.pyplot在X轴上绘制带有Date列的数据框。但是xticks较长且重叠,从而导致像this这样的图形。 如何正确管理xtick或使用只包含月份和年份(即1月17日)的其他xtick。 我用于绘制的代码:

plt.plot('Date','CODIn',data=df,marker='o',label='Influent')
plt.plot('Date','CODOut',data=df,marker='o',linestyle='dashed',label='Effluent')
plt.legend()    

0 个答案:

没有答案