Python 如何绘制时间戳分布图

Python 如何绘制时间戳分布图,python,pandas,matplotlib,Python,Pandas,Matplotlib,我试图绘制冠状病毒病例随时间变化的图表,但当我运行代码时,所有的时间戳都被挤压在一起。我希望将它们分开,这样您就可以实际读取索引并查看有多少时间。 这是我用来绘制图表的代码: washcases.plot.bar(rot=15,title=“Washtenaw县每天案例”),我的数据如下所示: 2020-03-01 0 2020-03-02 0 2020-03-03 0 2020-03-04 0 2020-03-05 3 2020-03-06 1

我试图绘制冠状病毒病例随时间变化的图表,但当我运行代码时,所有的时间戳都被挤压在一起。我希望将它们分开,这样您就可以实际读取索引并查看有多少时间。

这是我用来绘制图表的代码:
washcases.plot.bar(rot=15,title=“Washtenaw县每天案例”)
,我的数据如下所示:

2020-03-01     0
2020-03-02     0
2020-03-03     0
2020-03-04     0
2020-03-05     3
2020-03-06     1
2020-03-07     5
有人能帮我把时间戳的可读性更好的数据用图表表示出来吗?谢谢大家!

我看过的帖子:


您可以减少x轴上显示的标签数量,如下所示:

import matplotlib.pyplot as plt

# your code for loading the data and plotting

# get the current axis
ax = plt.gca()
# set the number of labels (e.g. 10)
ax.xaxis.set_major_locator(plt.MaxNLocator(10)) 

plt.show()  

可以按如下方式减少x轴上显示的标签数量:

import matplotlib.pyplot as plt

# your code for loading the data and plotting

# get the current axis
ax = plt.gca()
# set the number of labels (e.g. 10)
ax.xaxis.set_major_locator(plt.MaxNLocator(10)) 

plt.show()