X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=covid19.py;h=e633b03c8e99b69276288d999dbbb518f1efcb69;hb=65d1b3f2d428743f157e4180306adbad7829cba2;hp=0fd9ecce161716c65cd94b85069c5ff8e58733e5;hpb=0db243241c0ec4515e6484ad3e7195dc3f015e8b;p=python.git diff --git a/covid19.py b/covid19.py index 0fd9ecc..e633b03 100755 --- a/covid19.py +++ b/covid19.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import matplotlib.dates as mdates import urllib.request -url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv' +url = 'https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv' file = 'time_series_19-covid-Confirmed.csv' @@ -44,8 +44,8 @@ with open(file, newline='') as csvfile: fig = plt.figure() ax = fig.add_subplot(1, 1, 1) -ax.grid(color='gray', linestyle='-', linewidth=0.25) - +# 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) ax.set_yscale('log') @@ -54,17 +54,22 @@ myFmt = mdates.DateFormatter('%b %d') ax.xaxis.set_major_formatter(myFmt) dates = mdates.epoch2num(times) -for label, color in [ ('World', 'blue'), - ('Switzerland', 'red'), - ('France', 'green'), - ('South Korea', 'gray'), - ('Mainland China', 'orange') ]: - ax.plot(dates, nb_cases[label], color = color, label = label) +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) +]: + delta = 0 + ax.plot(dates[:dates.shape[0]-delta], nb_cases[key][delta:], 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() -# fig.savefig('covid19.svg') +fig.savefig('covid19.png') ######################################################################