From 73ff8feeb7fc00c5cf392dd5c7399ab06ab807fa Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Thu, 12 Mar 2020 14:25:48 +0100 Subject: [PATCH] Update. --- covid19.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/covid19.py b/covid19.py index e633b03..ea79544 100755 --- a/covid19.py +++ b/covid19.py @@ -1,5 +1,10 @@ #!/usr/bin/env python +# Any copyright is dedicated to the Public Domain. +# https://creativecommons.org/publicdomain/zero/1.0/ + +# Written by Francois Fleuret + import os, time, math import numpy, csv import matplotlib.pyplot as plt @@ -29,7 +34,6 @@ with open(file, newline='') as csvfile: country = field if not country in nb_cases: nb_cases[country] = numpy.zeros(len(times)) - # print(country) if row_nb == 0 and col_nb >= time_col: times.append(time.mktime(time.strptime(field, '%m/%d/%y'))) if row_nb == 1 and col_nb == time_col: @@ -44,7 +48,6 @@ with open(file, newline='') as csvfile: fig = plt.figure() ax = fig.add_subplot(1, 1, 1) -# ax.grid ax.yaxis.grid(color='gray', linestyle='-', linewidth=0.25) ax.set_title('Nb. of COVID-19 cases') ax.set_xlabel('Date', labelpad = 10) @@ -54,19 +57,20 @@ myFmt = mdates.DateFormatter('%b %d') ax.xaxis.set_major_formatter(myFmt) dates = mdates.epoch2num(times) -for key, color, label, delta in [ - ('World', 'blue', 'World', 0), - ('Switzerland', 'red', 'Switzerland', 14), - ('France', 'lightgreen', 'France', 11), - ('US', 'black', 'USA', 14), - ('Korea, South', 'gray', 'S. Korea', 0), - ('Italy', 'purple', 'Italy', 3), - ('China', 'orange', 'China', 0) +print('Countries:') +print(nb_cases.keys()) + +for key, color, label in [ + ('World', 'blue', 'World'), + ('Switzerland', 'red', 'Switzerland'), + ('France', 'lightgreen', 'France'), + ('US', 'black', 'USA'), + ('Korea, South', 'gray', 'South Korea'), + ('Italy', 'purple', 'Italy'), + ('China', 'orange', 'China') ]: - delta = 0 - ax.plot(dates[:dates.shape[0]-delta], nb_cases[key][delta:], color = color, label = label, linewidth=2) + ax.plot(dates, nb_cases[key], color = color, label = label, linewidth=2) -# ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon = False) ax.legend(frameon = False) plt.show() -- 2.20.1