🐛 FIXED: Highlighting didnt work properly
This commit is contained in:
parent
75fae905bf
commit
1b8cabb2b5
44
Analyser.py
44
Analyser.py
|
@ -62,7 +62,7 @@ class Analyser:
|
|||
return retList
|
||||
|
||||
def getCasesGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d'),
|
||||
showPlot=False) -> str:
|
||||
plotDpi=200.0, showPlot=False) -> str:
|
||||
"""
|
||||
Get a graph with the absolute number of cases by day for the entered country
|
||||
:param country: The country you wish to get the graph for
|
||||
|
@ -73,7 +73,7 @@ class Analyser:
|
|||
"""
|
||||
if country in self.getAvailableCountries():
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title(('Total cases in ' + country))
|
||||
|
||||
|
@ -98,7 +98,7 @@ class Analyser:
|
|||
return '-1'
|
||||
|
||||
def getCaseIncreaseGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d'),
|
||||
showPlot=False) -> str:
|
||||
plotDpi=200.0, showPlot=False) -> str:
|
||||
"""
|
||||
Get a graph with the daily increase number of cases for the entered country
|
||||
:param country: The country you wish to get the graph for
|
||||
|
@ -109,7 +109,7 @@ class Analyser:
|
|||
"""
|
||||
if country in self.getAvailableCountries():
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title(('Daily new cases in ' + country))
|
||||
|
||||
|
@ -146,7 +146,7 @@ class Analyser:
|
|||
return countryTimeData['cases'].sum()
|
||||
|
||||
def getDeathGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d'),
|
||||
showPlot=False) -> str:
|
||||
plotDpi=200.0, showPlot=False) -> str:
|
||||
"""
|
||||
Get a graph with the absolute number of cases by day for the entered country
|
||||
:param country: The country you wish to get the graph for
|
||||
|
@ -157,7 +157,7 @@ class Analyser:
|
|||
"""
|
||||
if country in self.getAvailableCountries():
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title(('Total deaths in ' + country))
|
||||
|
||||
|
@ -182,7 +182,7 @@ class Analyser:
|
|||
return '-1'
|
||||
|
||||
def getDeathIncreaseGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d'),
|
||||
showPlot=False) -> str:
|
||||
plotDpi=200.0, showPlot=False) -> str:
|
||||
"""
|
||||
Get a graph with the daily increase number of cases for the entered country
|
||||
:param country: The country you wish to get the graph for
|
||||
|
@ -193,7 +193,7 @@ class Analyser:
|
|||
"""
|
||||
if country in self.getAvailableCountries():
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title(('Daily new deaths in ' + country))
|
||||
|
||||
|
@ -230,7 +230,7 @@ class Analyser:
|
|||
return countryTimeData['deaths'].sum()
|
||||
|
||||
def getDailyDeathRateGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d'),
|
||||
showPlot=False) -> str:
|
||||
plotDpi=200.0, showPlot=False) -> str:
|
||||
"""
|
||||
Get a graph with the daily increase number of cases for the entered country
|
||||
:param country: The country you wish to get the graph for
|
||||
|
@ -241,7 +241,7 @@ class Analyser:
|
|||
"""
|
||||
if country in self.getAvailableCountries():
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title(('Daily death rate in ' + country) + ' in %')
|
||||
|
||||
|
@ -277,7 +277,7 @@ class Analyser:
|
|||
countryTimeData = countryData.loc[mask]
|
||||
return (countryTimeData['deaths'].sum() / countryTimeData['cases'].sum() * 100)
|
||||
|
||||
def getIsItOverGraph(self, country, showPlot=False) -> str:
|
||||
def getIsItOverGraph(self, country, plotDpi=200.0, showPlot=False) -> str:
|
||||
"""
|
||||
Get a logarhytmic graph that shows easily if the exponential growth has stopped.
|
||||
:param country: The country to be compared. TODO: Change to a list of countries
|
||||
|
@ -286,7 +286,7 @@ class Analyser:
|
|||
"""
|
||||
countryString = country
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title('Is it going to end soon in ' + countryString + '?')
|
||||
ax.set_ylabel('Case Increase')
|
||||
|
@ -310,9 +310,9 @@ class Analyser:
|
|||
return filePath
|
||||
|
||||
def getIncreasePercentageGraph(self, country, start_date='2019-12-31', end_date=datetime.now().strftime('%Y-%m-%d'),
|
||||
showPlot=False) -> str:
|
||||
plotDpi=200.0, showPlot=False) -> str:
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title('Daily Percentage of Case Increase in ' + country)
|
||||
|
||||
|
@ -334,9 +334,9 @@ class Analyser:
|
|||
|
||||
return filePath
|
||||
|
||||
def getCasesPerMillionGraph(self, country, showPlot=False) -> str:
|
||||
def getCasesPerMillionGraph(self, country, plotDpi=200.0, showPlot=False) -> str:
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title('Cases per Million Citizens in ' + country + ' compared to top 20')
|
||||
|
||||
|
@ -351,12 +351,14 @@ class Analyser:
|
|||
if country not in largestData['countriesAndTerritories'].unique():
|
||||
largestData = largestData.append(timeData.loc[timeData['countriesAndTerritories'] == country])
|
||||
|
||||
largestData = largestData.reset_index()
|
||||
largestData.plot.bar(ax=ax, x="countriesAndTerritories", y="casesPerMillion")
|
||||
|
||||
# Highlight the selected country
|
||||
for ticks in ax.xaxis.get_major_ticks():
|
||||
if ticks.label1.get_text() == country:
|
||||
ax.patches[largestData.index.get_indexer([ticks.label1.get_text])[0]].set_facecolor('r')
|
||||
index = largestData.index[largestData['countriesAndTerritories'] == country]
|
||||
ax.patches[int(index.values[0])].set_facecolor('r')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
@ -366,9 +368,9 @@ class Analyser:
|
|||
|
||||
return filePath
|
||||
|
||||
def getDeathsPerMillionGraph(self, country, showPlot=False) -> str:
|
||||
def getDeathsPerMillionGraph(self, country, plotDpi=200.0, showPlot=False) -> str:
|
||||
fig = plt.figure()
|
||||
fig.dpi = 200.0
|
||||
fig.dpi = plotDpi
|
||||
ax = fig.add_subplot(111)
|
||||
plt.title('Deaths per Million Citizens in ' + country + ' compared to top 20')
|
||||
|
||||
|
@ -383,12 +385,14 @@ class Analyser:
|
|||
if country not in largestData['countriesAndTerritories'].unique():
|
||||
largestData = largestData.append(timeData.loc[timeData['countriesAndTerritories'] == country])
|
||||
|
||||
largestData = largestData.reset_index()
|
||||
largestData.plot.bar(ax=ax, x="countriesAndTerritories", y="deathsPerMillion")
|
||||
|
||||
# Highlight the selected country
|
||||
for ticks in ax.xaxis.get_major_ticks():
|
||||
if ticks.label1.get_text() == country:
|
||||
ax.patches[largestData.index.get_indexer([ticks.label1.get_text])[0]].set_facecolor('r')
|
||||
index = largestData.index[largestData['countriesAndTerritories'] == country]
|
||||
ax.patches[int(index.values[0])].set_facecolor('r')
|
||||
|
||||
if showPlot:
|
||||
plt.show(block=True)
|
||||
|
|
209
statsfile.csv
209
statsfile.csv
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user