【发布时间】:2020-10-14 16:11:03
【问题描述】:
我的 Matplotlib 图表需要一些帮助。项目可以查看here(目前在new-graph分支下工作)。
作为这个项目所做的总结:
- 下载两个 CSV 文件(英国 COVID-19 病例和英国 COVID-19 死亡病例)
- 将 CSV 文件解析为 Pandas 数据框,以仅包含包含日期和累积值的列
- 使用 Matplotlib 条形图将这两组数据绘制在一张图上
我的问题是 Matplotlib 不会自动分隔 X 轴值(日期)。我不确定是不是因为 Matplotlib 没有将它们识别为日期或我犯的其他错误。 Here is what the graph currently looks like.
编辑: 抱歉,我忘了将代码添加到问题中。在这里……
import matplotlib.pyplot as plt
def plot(cases,deaths):
#cases.plot(x='Specimen date',y='Cumulative lab-confirmed cases',color='green')
#deaths.plot(x='Reporting date',y='Cumulative deaths',color='red')
plt.figure("Cumulative deaths and cases")
ax = plt.gca()
cases.plot(kind='bar', x='Specimen date', y='Cumulative lab-confirmed cases',ax=ax, color='green')
deaths.plot(kind='bar', x='Reporting date', y='Cumulative deaths', ax=ax, color='red')
plt.show()
【问题讨论】:
-
请在问题正文中包含您的代码,以便人们更容易地帮助您。
-
完全忘记了这一点。我已经修好了,对不起!
标签: python pandas matplotlib graph statistics