Saving the graphs as file

- WIP, Saved graphs are currently empty pictures for some reason
This commit is contained in:
Patrick Müller 2020-03-29 12:21:50 +02:00
parent b8c9b58cc2
commit e5be34dd55
2 changed files with 10 additions and 9 deletions

View File

@ -56,18 +56,18 @@ class Analyser:
countryTimeData = countryTimeData.sort_values('dateRep')
countryTimeData['cases'] = countryTimeData['cases'].cumsum()
print(countryTimeData.head())
print(countryTimeData)
countryTimeData.plot(ax=ax, x='dateRep', y='cases')
plt.show(block=True)
filePath = ('graphs/casesGraph_' + country + '_' + datetime.now().strftime('%Y-%m-%d'))
plt.savefig(filePath)
# TODO Change return
return 'abc'
return filePath
else:
print('Unknown country')
# TODO Change return
return 'abc'
return '-1'
def getCaseIncreaseGraph(self, country):
"""
@ -90,13 +90,13 @@ class Analyser:
countryTimeData.plot(ax=ax, x='dateRep', y='cases')
plt.show(block=True)
filePath = ('graphs/casesIncreaseGraph_' + country + '_' + datetime.now().strftime('%Y-%m-%d'))
plt.savefig(filePath)
# TODO Change return
return 'abc'
return filePath
else:
print('Unknown country')
# TODO Change return
return 'abc'
return '-1'
def getTotalCases(self, country, date=datetime.now().strftime('%Y-%m-%d')) -> int:
"""

View File

@ -13,4 +13,5 @@ if __name__ == '__main__':
country = input('What country do you want the graph for: ')
analyser.getCasesGraph(country, start_date='2020-02-14')
print(analyser.getTotalCases(country))
analyser.getCaseIncreaseGraph(country)
fetcher.updateStatsFile()